From b6383c8a4ab3cbf78d8ad00bbfc49bb53aab0006 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Sun, 3 Sep 2023 14:01:32 +0100 Subject: [PATCH] ci(generate): check for `USERSTYLES_TOKEN` In order to bypass repository rulesets, the repository must be cloned with a PAT. This commit adds 2 steps to clone the repository, one where the PAT exists and one where it does not. This should allow the action to succeed on main and on forked repositories. --- .github/workflows/generate.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 077535d..ba1a922 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -8,6 +8,7 @@ on: env: DENO_DIR: deno_cache + HAS_USERSTYLES_TOKEN: ${{ secrets.USERSTYLES_TOKEN != '' }} jobs: generate-health-files: @@ -19,7 +20,16 @@ jobs: contents: write steps: - - uses: actions/checkout@v3 + - name: Check Out Repository + uses: actions/checkout@v3 + if: ${{ env.HAS_USERSTYLES_TOKEN }} + with: + token: ${{ secrets.USERSTYLES_TOKEN }} + ref: ${{ github.ref }} + + - name: Check Out Repository (Fork) + uses: actions/checkout@v3 + if: "!${{ env.HAS_USERSTYLES_TOKEN }}" with: ref: ${{ github.ref }} @@ -40,7 +50,7 @@ jobs: - name: Push Changes uses: stefanzweifel/git-auto-commit-action@v4 - if: ${{ github.repository == 'catppuccin/userstyles' && github.ref == 'refs/heads/main' }} + if: ${{ github.repository == 'catppuccin/userstyles' && github.ref == 'refs/heads/main' && env.HAS_USERSTYLES_TOKEN }} with: commit_message: "chore: generate health files" commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"