From 54d71dafb6551f6158f7d644a154b58a9b5faa14 Mon Sep 17 00:00:00 2001 From: uncenter <47499684+uncenter@users.noreply.github.com> Date: Tue, 30 Jan 2024 21:02:04 -0500 Subject: [PATCH 1/6] ci: replace format & generate with update-files workflow --- .github/workflows/format.yml | 30 ------------- .github/workflows/generate.yml | 46 -------------------- .github/workflows/update-files.yml | 67 ++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 76 deletions(-) delete mode 100644 .github/workflows/format.yml delete mode 100644 .github/workflows/generate.yml create mode 100644 .github/workflows/update-files.yml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml deleted file mode 100644 index 9bfdabdb98..0000000000 --- a/.github/workflows/format.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Format - -on: - push: - branches: [main] - -jobs: - format: - name: Format userstyles - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - token: ${{ secrets.USERSTYLES_TOKEN }} - - - name: Setup Node.js - uses: actions/setup-node@v3 - - - name: Format userstyles - run: npx prettier --write . - - - name: Pull changes - run: git pull - - - name: Push changes - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: "style: format code with prettier" - commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml deleted file mode 100644 index 25cb5603d1..0000000000 --- a/.github/workflows/generate.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: File Generator - -on: - workflow_dispatch: - push: - paths: - - "scripts/**/*" - -env: - HAS_USERSTYLES_TOKEN: ${{ secrets.USERSTYLES_TOKEN != '' }} - -jobs: - generate-health-files: - name: Generate health files - runs-on: ubuntu-latest - permissions: - # Give the default GITHUB_TOKEN write permission to commit and push the - # added or changed files to the repository. - contents: write - - steps: - - uses: actions/checkout@v4 - if: env.HAS_USERSTYLES_TOKEN - with: - token: ${{ secrets.USERSTYLES_TOKEN }} - ref: ${{ github.ref }} - - uses: actions/checkout@v4 - if: env.HAS_USERSTYLES_TOKEN == 'false' - with: - ref: ${{ github.ref }} - - - name: Setup Deno - uses: nekowinston/setup-deno@main - with: - deno-version: v1.x - - - name: Generate health files - run: deno task ci:generate - - - name: Push changes - uses: stefanzweifel/git-auto-commit-action@v5 - 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>" - branch: ${{ github.ref }} diff --git a/.github/workflows/update-files.yml b/.github/workflows/update-files.yml new file mode 100644 index 0000000000..af5d9e98e1 --- /dev/null +++ b/.github/workflows/update-files.yml @@ -0,0 +1,67 @@ +name: Update Files + +on: + workflow_dispatch: + push: + branches: [main] + +env: + HAS_USERSTYLES_TOKEN: ${{ secrets.USERSTYLES_TOKEN != '' }} + +jobs: + update-files: + name: Update files + runs-on: ubuntu-latest + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the + # added or changed files to the repository. + contents: write + + steps: + - uses: actions/checkout@v4 + if: env.HAS_USERSTYLES_TOKEN + with: + token: ${{ secrets.USERSTYLES_TOKEN }} + ref: ${{ github.ref }} + - uses: actions/checkout@v4 + if: env.HAS_USERSTYLES_TOKEN == 'false' + with: + ref: ${{ github.ref }} + + - name: Setup Deno + uses: nekowinston/setup-deno@main + with: + deno-version: v1.x + + - name: Generate health files + run: deno task ci:generate + + - name: Commit changes + uses: EndBug/add-and-commit@v9 + if: ${{ github.repository == 'catppuccin/userstyles' && github.ref == 'refs/heads/main' && env.HAS_USERSTYLES_TOKEN }} + with: + message: "chore: generate health files" + default_author: github_actions + push: false + + - name: Generate health files + run: deno task ci:generate + + - name: Commit changes + uses: EndBug/add-and-commit@v9 + if: ${{ github.repository == 'catppuccin/userstyles' && github.ref == 'refs/heads/main' && env.HAS_USERSTYLES_TOKEN }} + with: + message: "chore: generate health files" + default_author: github_actions + push: false + + - name: Format userstyles + run: npx prettier --write . + + - name: Commit changes + uses: EndBug/add-and-commit@v9 + if: ${{ github.repository == 'catppuccin/userstyles' && github.ref == 'refs/heads/main' && env.HAS_USERSTYLES_TOKEN }} + with: + message: "style: format code with prettier" + default_author: github_actions + push: true From c46ab3b24c17d0198294b546629295b82c1be0c7 Mon Sep 17 00:00:00 2001 From: uncenter <47499684+uncenter@users.noreply.github.com> Date: Tue, 30 Jan 2024 21:06:36 -0500 Subject: [PATCH 2/6] fix: oops how did that happen --- .github/workflows/update-files.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/update-files.yml b/.github/workflows/update-files.yml index af5d9e98e1..938e48140d 100644 --- a/.github/workflows/update-files.yml +++ b/.github/workflows/update-files.yml @@ -44,17 +44,6 @@ jobs: default_author: github_actions push: false - - name: Generate health files - run: deno task ci:generate - - - name: Commit changes - uses: EndBug/add-and-commit@v9 - if: ${{ github.repository == 'catppuccin/userstyles' && github.ref == 'refs/heads/main' && env.HAS_USERSTYLES_TOKEN }} - with: - message: "chore: generate health files" - default_author: github_actions - push: false - - name: Format userstyles run: npx prettier --write . From 0a352744848e6b401f4bd97e39b6f292607acc0f Mon Sep 17 00:00:00 2001 From: uncenter <47499684+uncenter@users.noreply.github.com> Date: Tue, 30 Jan 2024 21:15:31 -0500 Subject: [PATCH 3/6] refactor: back to stefanzweifel/git-auto-commit-action since pushing isnt cyclical --- .github/workflows/update-files.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/update-files.yml b/.github/workflows/update-files.yml index 938e48140d..075068c146 100644 --- a/.github/workflows/update-files.yml +++ b/.github/workflows/update-files.yml @@ -36,21 +36,21 @@ jobs: - name: Generate health files run: deno task ci:generate - - name: Commit changes - uses: EndBug/add-and-commit@v9 + - name: Push changes + uses: stefanzweifel/git-auto-commit-action@v5 if: ${{ github.repository == 'catppuccin/userstyles' && github.ref == 'refs/heads/main' && env.HAS_USERSTYLES_TOKEN }} with: - message: "chore: generate health files" - default_author: github_actions - push: false + commit_message: "chore: generate health files" + commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" + branch: ${{ github.ref }} - name: Format userstyles run: npx prettier --write . - - name: Commit changes - uses: EndBug/add-and-commit@v9 + - name: Push changes + uses: stefanzweifel/git-auto-commit-action@v5 if: ${{ github.repository == 'catppuccin/userstyles' && github.ref == 'refs/heads/main' && env.HAS_USERSTYLES_TOKEN }} with: - message: "style: format code with prettier" - default_author: github_actions - push: true + commit_message: "style: format code with prettier" + commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" + branch: ${{ github.ref }} From 2f32e072bbc3a930f785b821d5ee6d05ec51fcf9 Mon Sep 17 00:00:00 2001 From: uncenter <47499684+uncenter@users.noreply.github.com> Date: Tue, 30 Jan 2024 21:37:37 -0500 Subject: [PATCH 4/6] refactor: back to EndBug/add-and-commit, push once at end --- .github/workflows/update-files.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/update-files.yml b/.github/workflows/update-files.yml index 075068c146..2823c15dfa 100644 --- a/.github/workflows/update-files.yml +++ b/.github/workflows/update-files.yml @@ -36,21 +36,24 @@ jobs: - name: Generate health files run: deno task ci:generate - - name: Push changes - uses: stefanzweifel/git-auto-commit-action@v5 + - name: Commit changes + uses: EndBug/add-and-commit@v9 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>" - branch: ${{ github.ref }} + message: "chore: generate health files" + default_author: github_actions + push: false - name: Format userstyles run: npx prettier --write . - - name: Push changes - uses: stefanzweifel/git-auto-commit-action@v5 + - name: Commit changes + uses: EndBug/add-and-commit@v9 if: ${{ github.repository == 'catppuccin/userstyles' && github.ref == 'refs/heads/main' && env.HAS_USERSTYLES_TOKEN }} with: - commit_message: "style: format code with prettier" - commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" - branch: ${{ github.ref }} + message: "style: format code with prettier" + default_author: github_actions + push: false + + - name: Push changes + run: git push origin "HEAD:${{ github.ref }}" --atomic From 14b09fd4525ccdc24633ab5e85913d0911f81324 Mon Sep 17 00:00:00 2001 From: uncenter <47499684+uncenter@users.noreply.github.com> Date: Tue, 30 Jan 2024 21:47:59 -0500 Subject: [PATCH 5/6] refactor: rename workflow, job, and steps --- .../workflows/{update-files.yml => generate-format.yml} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename .github/workflows/{update-files.yml => generate-format.yml} (91%) diff --git a/.github/workflows/update-files.yml b/.github/workflows/generate-format.yml similarity index 91% rename from .github/workflows/update-files.yml rename to .github/workflows/generate-format.yml index 2823c15dfa..1f0d26f277 100644 --- a/.github/workflows/update-files.yml +++ b/.github/workflows/generate-format.yml @@ -1,4 +1,4 @@ -name: Update Files +name: Generate Health Files & Format on: workflow_dispatch: @@ -9,8 +9,8 @@ env: HAS_USERSTYLES_TOKEN: ${{ secrets.USERSTYLES_TOKEN != '' }} jobs: - update-files: - name: Update files + generate-health-files-and-format: + name: Generate health files & format runs-on: ubuntu-latest permissions: # Give the default GITHUB_TOKEN write permission to commit and push the @@ -44,7 +44,7 @@ jobs: default_author: github_actions push: false - - name: Format userstyles + - name: Format files run: npx prettier --write . - name: Commit changes From d6536385a93d019a06542be42b969837fdb98a69 Mon Sep 17 00:00:00 2001 From: uncenter <47499684+uncenter@users.noreply.github.com> Date: Wed, 31 Jan 2024 06:42:28 -0500 Subject: [PATCH 6/6] fix: move if check to push --- .github/workflows/generate-format.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/generate-format.yml b/.github/workflows/generate-format.yml index 1f0d26f277..30a0aac6e3 100644 --- a/.github/workflows/generate-format.yml +++ b/.github/workflows/generate-format.yml @@ -38,7 +38,6 @@ jobs: - name: Commit changes uses: EndBug/add-and-commit@v9 - if: ${{ github.repository == 'catppuccin/userstyles' && github.ref == 'refs/heads/main' && env.HAS_USERSTYLES_TOKEN }} with: message: "chore: generate health files" default_author: github_actions @@ -49,11 +48,11 @@ jobs: - name: Commit changes uses: EndBug/add-and-commit@v9 - if: ${{ github.repository == 'catppuccin/userstyles' && github.ref == 'refs/heads/main' && env.HAS_USERSTYLES_TOKEN }} with: message: "style: format code with prettier" default_author: github_actions push: false - name: Push changes + if: ${{ github.repository == 'catppuccin/userstyles' && github.ref == 'refs/heads/main' && env.HAS_USERSTYLES_TOKEN }} run: git push origin "HEAD:${{ github.ref }}" --atomic