-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from route06/feature
ワークフロー get_next_scheduled_date の追加およびcreate_discussionの改善
- Loading branch information
Showing
3 changed files
with
127 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# @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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters