From 01eac8e32fe7628c44585e130ad15c5030943e37 Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Tue, 30 Jan 2024 06:58:24 +0000 Subject: [PATCH] Enhancement (ci): Add `cron` workflow --- .github/workflows/cron.yml | 26 +++++++++++++++++ generate/definitions/FILES.ps1 | 1 + .../templates/.github/workflows/cron.yml.ps1 | 29 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 .github/workflows/cron.yml create mode 100644 generate/templates/.github/workflows/cron.yml.ps1 diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml new file mode 100644 index 0000000..39a8b38 --- /dev/null +++ b/.github/workflows/cron.yml @@ -0,0 +1,26 @@ +name: cron +on: + schedule: + # Run daily + - cron: '0 0 * * *' + workflow_dispatch: +jobs: + update-versions: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + # Admin user must generate a Personal Access Token with 'workflow' permissions, and used to populate the secret named WORKFLOW_TOKEN. + # See: https://stackoverflow.com/questions/68811838/refusing-to-allow-a-personal-access-token-to-create-or-update-workflow + # See: https://stackoverflow.com/questions/66643917/refusing-to-allow-a-github-app-to-create-or-update-workflow + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.WORKFLOW_TOKEN }} # This configures the git repo to use this token + fetch-depth: 0 # Fetch all branches and tags + - shell: pwsh + run: | + ./Update-Versions.ps1 -PR -AutoMergeQueue -AutoRelease + env: + GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} diff --git a/generate/definitions/FILES.ps1 b/generate/definitions/FILES.ps1 index f64d3bc..1ef7df4 100755 --- a/generate/definitions/FILES.ps1 +++ b/generate/definitions/FILES.ps1 @@ -1,6 +1,7 @@ # Files' definition $FILES = @( '.github/workflows/ci-master-pr.yml' + '.github/workflows/cron.yml' '.github/release-drafter.yml' 'README.md' ) diff --git a/generate/templates/.github/workflows/cron.yml.ps1 b/generate/templates/.github/workflows/cron.yml.ps1 new file mode 100644 index 0000000..559186e --- /dev/null +++ b/generate/templates/.github/workflows/cron.yml.ps1 @@ -0,0 +1,29 @@ +@' +name: cron +on: + schedule: + # Run daily + - cron: '0 0 * * *' + workflow_dispatch: +jobs: + update-versions: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + # Admin user must generate a Personal Access Token with 'workflow' permissions, and used to populate the secret named WORKFLOW_TOKEN. + # See: https://stackoverflow.com/questions/68811838/refusing-to-allow-a-personal-access-token-to-create-or-update-workflow + # See: https://stackoverflow.com/questions/66643917/refusing-to-allow-a-github-app-to-create-or-update-workflow + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.WORKFLOW_TOKEN }} # This configures the git repo to use this token + fetch-depth: 0 # Fetch all branches and tags + - shell: pwsh + run: | + ./Update-Versions.ps1 -PR -AutoMergeQueue -AutoRelease + env: + GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + +'@