diff --git a/.github/workflows/scheduled-slack-glossary-maintainers.yaml b/.github/workflows/scheduled-slack-glossary-maintainers.yaml index 164c11502..bccf9ac2d 100644 --- a/.github/workflows/scheduled-slack-glossary-maintainers.yaml +++ b/.github/workflows/scheduled-slack-glossary-maintainers.yaml @@ -3,10 +3,12 @@ name: "Slack scheduled message: CNCF Glossary WG reminder" on: workflow_dispatch: schedule: - # 4th Thursday is always the 22nd–28th, on weekday 4 (Thursday) - # Every 2 months starting January: Jan, Mar, May, Jul, Sep, Nov - # 00:00 UTC - - cron: "0 0 22-28 1,3,5,7,9,11 4" + # The meeting is on the 4th Thursday of every 2nd month (Jan, Mar, May, Jul, + # Sep, Nov) at 00:00 UTC. The 4th Thursday is always the 22nd–28th. + # cron ORs day-of-month and day-of-week when both are restricted, so a + # weekday here would add runs instead of narrowing them; the guard step + # below is what selects the Thursday. + - cron: "0 0 22-28 1,3,5,7,9,11 *" permissions: contents: none @@ -16,16 +18,22 @@ jobs: if: github.repository == 'cncf/automation' runs-on: ubuntu-latest steps: - - name: "Guard: only run on 4th Thursday" + - name: "Guard: only run on 4th Thursday" + id: guard shell: bash run: | day_of_week=$(date -u +%u) # 1=Mon, 4=Thu, 7=Sun - day_of_month=$(date -u +%d) + day_of_month=$((10#$(date -u +%d))) # base 10 so 08/09 are not read as octal if [[ "$day_of_week" != "4" || "$day_of_month" -lt 22 || "$day_of_month" -gt 28 ]]; then - echo "Not the 4th Thursday (day_of_week=$day_of_week, day_of_month=$day_of_month). Exiting." - exit 0 + echo "Not the 4th Thursday (day_of_week=$day_of_week, day_of_month=$day_of_month). Skipping." + echo "post=false" >> "$GITHUB_OUTPUT" + else + echo "post=true" >> "$GITHUB_OUTPUT" fi - name: Post message to Slack + # exit 0 in the guard only ends that step; the job keeps going. Gate on + # the guard's output instead. Manual runs always post. + if: github.event_name == 'workflow_dispatch' || steps.guard.outputs.post == 'true' uses: rtCamp/action-slack-notify@33ca3be66c6f378fe1610fd1d5258632dbed5e58 # v2.4.0 env: SLACK_ICON: https://github.com/cncf.png?size=48