From 2c4eefa877f81a885ccb1a4e6429f9c071bccb43 Mon Sep 17 00:00:00 2001 From: uncenter <47499684+uncenter@users.noreply.github.com> Date: Sun, 29 Dec 2024 11:02:44 -0500 Subject: [PATCH] ci: clean up and simplify workflows (#1541) --- .../workflows/{lint-build.yml => build.yml} | 28 +++---------------- .github/workflows/ci.yml | 14 +--------- .github/workflows/deno-check.yml | 4 +-- .github/workflows/deno-lock.yml | 2 +- .github/workflows/issues.yml | 1 - .github/workflows/lint.yml | 25 +++++++++++++++++ .github/workflows/maintainers.yml | 9 ++---- .github/workflows/pull-requests.yml | 4 +-- .github/workflows/sync-labels.yml | 8 ++---- .github/workflows/website.yml | 7 ++--- 10 files changed, 43 insertions(+), 59 deletions(-) rename .github/workflows/{lint-build.yml => build.yml} (53%) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint-build.yml b/.github/workflows/build.yml similarity index 53% rename from .github/workflows/lint-build.yml rename to .github/workflows/build.yml index b9ad045a..2f32b264 100644 --- a/.github/workflows/lint-build.yml +++ b/.github/workflows/build.yml @@ -1,34 +1,15 @@ -name: Lint & Build +name: Build Stylus Export on: workflow_dispatch: - pull_request: - paths-ignore: ["docs/**"] push: branches: [main] paths-ignore: ["docs/**"] jobs: - lint: - name: Lint Userstyles - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Setup Deno - uses: nekowinston/setup-deno@main - with: - deno-version: v2.1.3 - - - name: Run Lint - run: deno task lint - build: - name: Generate Stylus Export + if: github.repository == 'catppuccin/userstyles' runs-on: ubuntu-latest - needs: lint - if: ${{ github.repository == 'catppuccin/userstyles' && github.ref == 'refs/heads/main' }} permissions: # Give the default GITHUB_TOKEN write permission to commit and push the # added or changed files to the repository. @@ -38,17 +19,16 @@ jobs: - uses: actions/checkout@v4 with: token: ${{ secrets.USERSTYLES_TOKEN }} - ref: ${{ github.ref }} - name: Setup Deno uses: nekowinston/setup-deno@main with: deno-version: v2.1.3 - - name: Generate Stylus import file + - name: Generate Stylus import run: deno task stylus-import - - name: Upload Release Artifacts + - name: Upload release artifact run: gh release upload --clobber all-userstyles-export ./dist/import.json env: GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 50e62488..ba48413d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,13 +1,9 @@ name: CI on: - workflow_dispatch: push: branches: [main] -env: - HAS_USERSTYLES_TOKEN: ${{ secrets.USERSTYLES_TOKEN != '' }} - jobs: ci: runs-on: ubuntu-latest @@ -17,18 +13,11 @@ jobs: contents: write # Prevent infinite loops by checking if the last commit was autogenerated. - if: ${{ github.event.commits[0].author.name != 'github-actions' }} + if: ${{ github.repository == 'catppuccin/userstyles' && github.event.commits[0].author.name != 'github-actions' }} steps: - uses: actions/checkout@v4 - if: env.HAS_USERSTYLES_TOKEN with: token: ${{ secrets.USERSTYLES_TOKEN }} - ref: ${{ github.ref }} - fetch-depth: 2 - - uses: actions/checkout@v4 - if: env.HAS_USERSTYLES_TOKEN == 'false' - with: - ref: ${{ github.ref }} fetch-depth: 2 - name: Setup Deno @@ -68,5 +57,4 @@ jobs: 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 diff --git a/.github/workflows/deno-check.yml b/.github/workflows/deno-check.yml index d85a32fb..2daa2f61 100644 --- a/.github/workflows/deno-check.yml +++ b/.github/workflows/deno-check.yml @@ -9,8 +9,8 @@ on: paths: ["**/*.ts"] jobs: - deno-check: - name: Check Deno code + check: + if: github.repository == 'catppuccin/userstyles' runs-on: ubuntu-latest steps: diff --git a/.github/workflows/deno-lock.yml b/.github/workflows/deno-lock.yml index 6518b870..116e4e0c 100644 --- a/.github/workflows/deno-lock.yml +++ b/.github/workflows/deno-lock.yml @@ -23,7 +23,7 @@ jobs: - name: Regenerate Deno lock run: deno cache **/*.ts --lock=deno.lock - - name: Commit & Push + - name: Commit & push changes uses: EndBug/add-and-commit@v9 with: message: "chore: regenerate `deno.lock`" diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml index 48dca65c..20cb94ca 100644 --- a/.github/workflows/issues.yml +++ b/.github/workflows/issues.yml @@ -7,7 +7,6 @@ on: jobs: triage: - name: Add labels runs-on: ubuntu-latest steps: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..f26be4d9 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +name: Lint Userstyles + +on: + workflow_dispatch: + pull_request: + paths-ignore: ["docs/**"] + push: + branches: [main] + paths-ignore: ["docs/**"] + +jobs: + lint: + if: github.repository == 'catppuccin/userstyles' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup Deno + uses: nekowinston/setup-deno@main + with: + deno-version: v2.1.3 + + - name: Lint + run: deno task lint diff --git a/.github/workflows/maintainers.yml b/.github/workflows/maintainers.yml index c733a200..aa3adf55 100644 --- a/.github/workflows/maintainers.yml +++ b/.github/workflows/maintainers.yml @@ -3,18 +3,16 @@ name: Sync Maintainers on: workflow_dispatch: push: - paths: - - "scripts/userstyles.yml" + branches: [main] + paths: ["scripts/userstyles.yml"] jobs: sync-maintainers: - name: Sync maintainers + if: github.repository == 'catppuccin/userstyles' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - with: - ref: ${{ github.ref }} - name: Setup Deno uses: nekowinston/setup-deno@main @@ -22,7 +20,6 @@ jobs: deno-version: v2.1.3 - name: Sync maintainers - if: ${{ github.repository == 'catppuccin/userstyles' && github.ref == 'refs/heads/main' }} run: deno task sync-maintainers env: GITHUB_TOKEN: ${{ secrets.USERSTYLES_TOKEN }} diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index 511a89e9..259b9ea0 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -5,9 +5,8 @@ on: jobs: triage: - name: Add labels runs-on: ubuntu-latest - if: ${{ !contains(github.event.pull_request.title, '(tree-wide)') }} + if: ${{ !contains(github.event.pull_request.title, '(tree-wide)') || !contains(github.event.pull_request.title, '(treewide)') }} steps: - uses: actions/checkout@v4 @@ -19,4 +18,3 @@ jobs: sync-labels: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index d7300966..8862ff28 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -4,17 +4,15 @@ on: workflow_dispatch: push: branches: [main] - paths: - - ".github/labels.yml" + paths: [".github/labels.yml"] jobs: - update: - name: Sync labels + sync: + if: github.repository == 'catppuccin/userstyles' runs-on: ubuntu-latest steps: - name: Sync labels uses: r7kamura/github-label-sync-action@v0 - if: ${{ github.repository == 'catppuccin/userstyles' }} with: allow_added_labels: "true" diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 4f5cfcbf..b290c794 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -3,19 +3,18 @@ name: Deploy Website on: workflow_dispatch: push: - branches: ["main"] + branches: [main] paths: ["scripts/userstyles.yml"] jobs: deploy: - runs-on: ubuntu-latest if: github.repository == 'catppuccin/userstyles' + runs-on: ubuntu-latest + environment: website - name: Vercel Deploy steps: - name: Deploy via cURL shell: bash env: DEPLOY_HOOK: ${{ secrets.VERCEL_DEPLOY_HOOK }} run: curl -X POST "$DEPLOY_HOOK" -# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json