Skip to content

Commit

Permalink
fix: run requirements cron job on even weeks only
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Feb 1, 2022
1 parent 32ad421 commit 1a6ed03
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion .github/workflows/requirements-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@ name: Requirements (scheduled)

on:
schedule:
- cron: "0 2 */14 * *"
- cron: "0 2 * * 1"
workflow_dispatch:

jobs:
is-even-week:
name: Check week number is even
runs-on: ubuntu-20.04
steps:
- name: Determine if week number is even
run: |
WEEK_NUMBER=$(date +%U)
IS_EVEN_WEEK="$(($WEEK_NUMBER % 2 == 0))"
echo "This is week $WEEK_NUMBER. It even week: $IS_EVEN_WEEK"
echo ::set-output name=is-even-week::"$IS_EVEN_WEEK"
id: is-even-week
outputs:
is-even-week: ${{ steps.is-even-week.outputs.is-even-week }}

pip-constraints:
name: Update pip constraints files
needs: is-even-week
if: needs.is-even-week.outputs.is-even-week != 0
runs-on: ubuntu-20.04
strategy:
fail-fast: false
Expand All @@ -26,6 +42,8 @@ jobs:

pre-commit:
name: pre-commit autoupdate
needs: is-even-week
if: needs.is-even-week.outputs.is-even-week != 0
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
Expand Down

0 comments on commit 1a6ed03

Please sign in to comment.