From d0b3c8727f587f4762bc1cedaaf535e3121ff744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Tue, 26 Nov 2024 14:41:08 +0100 Subject: [PATCH] chore(ci): fix perpetual generate workflow --- .github/workflows/generate_on_pr.yaml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/generate_on_pr.yaml b/.github/workflows/generate_on_pr.yaml index b371ec8..e851a2d 100644 --- a/.github/workflows/generate_on_pr.yaml +++ b/.github/workflows/generate_on_pr.yaml @@ -9,11 +9,34 @@ on: - synchronize jobs: + should-generate: + permissions: + contents: read + runs-on: + - ubuntu-latest + outputs: + result: ${{ steps.decision.outputs.result }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} + token: ${{ secrets.PAT }} + - id: decision + run: | + if [[ "$(git show -s --format=%B HEAD)" == "Update provider based on openapi.yaml changes" ]]; then + echo "result=false" >> "$GITHUB_OUTPUT" + else + echo "result=true" >> "$GITHUB_OUTPUT" + fi + generate: + needs: + - should-generate permissions: contents: write runs-on: - ubuntu-latest + if: needs.should-generate.outputs.result == 'true' steps: - name: Install Speakeasy uses: mheap/setup-go-cli@v1 @@ -28,6 +51,8 @@ jobs: with: ref: ${{ github.event.pull_request.head.ref }} token: ${{ secrets.PAT }} + # NOTE: no PAT as that would cause perpertual loop of commits to a PR. + # Unless we figure out how to detect - name: Configure speakeasy CLI run: |