Skip to content

Automatically Move Iteration Forward #25

Automatically Move Iteration Forward

Automatically Move Iteration Forward #25

name: Automatically Move Iteration Forward
on:
schedule:
# Runs "at 05:00, only on Wednesday"
- cron: '0 5 * * 3'
env:
# The date of the first run of the action. It has to be set to a date that is on the same weekday as the cron.
# 07/24 is a Wednesday, so the cron is set to run on Wednesday.
# Every second week of the bi-weekly cycle, the action is going to be skipped.
# The cron time can be set to any time of the day.
FIRST_RUN_DATE: 2024-07-24
jobs:
weekindex:
runs-on: ubuntu-latest
outputs:
weekindex: ${{ steps.calculate.outputs.weekindex }}
steps:
- name: Calculate weekdiff
id: calculate
run: |
current_date=$(date +%Y-%m-%d)
start=$(date -d ${{ env.FIRST_RUN_DATE }} +%s)
end=$(date -d $current_date +%s)
weekdiff=$(((end-start) / 60 / 60 / 24 / 7))
weekindex=$((weekdiff % 2))
echo "weekindex=$weekindex" >> "$GITHUB_OUTPUT"
echo "FIRST_RUN_DATE: ${{ env.FIRST_RUN_DATE }}" >> $GITHUB_STEP_SUMMARY
echo "current_date: $current_date" >> $GITHUB_STEP_SUMMARY
echo "weekdiff: $weekdiff" >> $GITHUB_STEP_SUMMARY
echo "weekindex: $weekindex" >> $GITHUB_STEP_SUMMARY
if [ $weekindex -eq 0 ]; then
echo "🟢 It's the first week of the bi-weekly cycle. The action is going to run." >> $GITHUB_STEP_SUMMARY
else
echo "🔴 It's the second week of the bi-weekly cycle. The action is going to be skipped." >> $GITHUB_STEP_SUMMARY
fi
move-to-next-iteration:
name: Move to next iteration
if: ${{ needs.weekindex.outputs.weekindex == 0 }}
needs: weekindex
runs-on: ubuntu-latest
steps:
- uses: blombard/move-to-next-iteration@master
with:
owner: CDCgov
number: 33
token: ${{ secrets.PROJECTS_MOVE_TO_NEXT_ITERATION }}
iteration-field: Current Sprint
iteration: last
new-iteration: current
excluded-statuses: "Done"