-
Notifications
You must be signed in to change notification settings - Fork 2
73 lines (69 loc) · 1.88 KB
/
calc_next_date.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# ## Summary
#
# Calculates a next date from the given arguments.
# ## Usage
#
# name: Calc next date
#
# on:
# workflow_dispatch:
#
# jobs:
# calc_next_weekly_date:
# uses: route06/actions/.github/workflows/calc_next_date.yml@v2
# with:
# interval: weekly
# target_day: wednesday
#
# log_result:
# runs-on: ubuntu-latest
# needs: [calc_next_weekly_date]
# steps:
# - name: Log the calculated next date
# run: |
# echo "The next weekly date is: ${{ needs.calc_next_weekly_date.outputs.next_date }}"
name: Calc next date
on:
workflow_call:
inputs:
interval:
description: daily, weeklyのいずれかを指定してください。
type: string
required: true
target_day:
description: intervalがweeklyの時は必須です。対象曜日を指定してください。
default: monday
type: string
time_zone:
description: タイムゾーンを指定してください。
default: "Asia/Tokyo"
type: string
outputs:
next_date:
description: yyyy/mm/dd形式で日付を返します。
value: ${{ jobs.calc_next_date.outputs.next_date }}
jobs:
calc_next_date:
runs-on: ubuntu-latest
timeout-minutes: 10
env:
TZ: ${{ inputs.time_zone }}
steps:
- name: Run script
id: calc_date
run: |
case "${{ inputs.interval }}" in
"daily")
next_date=$(date -d "tomorrow" +%Y/%m/%d)
;;
"weekly")
next_date=$(date -d "next ${{ inputs.target_day }}" +%Y/%m/%d)
;;
*)
echo "Invalid INTERVAL value"
exit 1
;;
esac
echo "next_date=$next_date" >> "$GITHUB_OUTPUT"
outputs:
next_date: ${{ steps.calc_date.outputs.next_date }}