From 70fe2d14798d2aa7d53f7320f70ed25984699397 Mon Sep 17 00:00:00 2001 From: Dafydd Jones Date: Thu, 31 Oct 2024 18:15:10 +0000 Subject: [PATCH] feat(workflows): improve workflows with actions `should-workflow-run` and `wait-for-checks` --- template/.github/workflows/main.yml | 30 +++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/template/.github/workflows/main.yml b/template/.github/workflows/main.yml index 5342f7b..f92022a 100644 --- a/template/.github/workflows/main.yml +++ b/template/.github/workflows/main.yml @@ -3,8 +3,19 @@ name: Main on: [push, pull_request] jobs: + should-run: + name: Should run + runs-on: ubuntu-latest + timeout-minutes: 5 + outputs: + should-run: ${{ steps.action.outputs.should-run }} + steps: + - id: action + uses: techneg-it/should-workflow-run@dcbb88600d59ec2842778ef1e2d41f680f876329 # v1.0.0 pre-commit: name: Run `pre-commit` + needs: should-run + if: fromJSON(needs.should-run.outputs.should-run) runs-on: ubuntu-latest env: # renovate: datasource=custom.python-versions depName=actions/python-versions versioning=pep440 @@ -17,6 +28,8 @@ jobs: - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 gv: name: Get value + needs: should-run + if: fromJSON(needs.should-run.outputs.should-run) runs-on: ubuntu-latest outputs: value: ${{ steps.get-value.outputs.value }} @@ -29,24 +42,29 @@ jobs: echo "::notice ::Value: ${{ steps.get-value.outputs.value }}" show-value: name: Show value - needs: gv + needs: + - gv + - should-run + if: fromJSON(needs.should-run.outputs.should-run) runs-on: ubuntu-latest steps: - run: | echo "::notice ::Value: $VALUE" env: VALUE: ${{ fromJSON(needs.gv.outputs.value) }} - release: - name: Release - needs: - - pre-commit - - show-value + results: + name: Collect results permissions: + checks: read contents: write issues: write pull-requests: write runs-on: ubuntu-latest steps: + - uses: poseidon/wait-for-status-checks@899c768d191b56eef585c18f8558da19e1f3e707 # v0.6.0 + with: + ignore: Collect results + token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Run `semantic-release` uses: codfish/semantic-release-action@9a999e0cdb207de2c9d9d4276860435727818989 # v3.4.1