From 5d851b837404afff177e5b758ef94f5b18e5d08e Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Wed, 31 Jul 2024 11:30:44 +0200 Subject: [PATCH] CI: Only build code if token exists (i.e. with Dependabot). --- .github/workflows/generated.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/generated.yml b/.github/workflows/generated.yml index 8bd2b51c..5090cd7d 100644 --- a/.github/workflows/generated.yml +++ b/.github/workflows/generated.yml @@ -28,10 +28,27 @@ permissions: contents: read jobs: + check-token: + runs-on: ubuntu-latest + outputs: + token-exists: ${{ steps.token-check.outputs.defined }} + steps: + - name: Check for Token availability + id: token-check + # perform secret check & put boolean result as an output + shell: bash + run: | + if [ "${{ secrets.CODE_GENERATOR_PAT }}" != '' ]; then + echo "defined=true" >> $GITHUB_OUTPUT; + else + echo "defined=false" >> $GITHUB_OUTPUT; + fi + build: - if: ${{ github.event_name == 'pull_request' }} name: build runs-on: ubuntu-latest + needs: [check-token] + if: ${{ github.event_name == 'pull_request' && needs.check-token.outputs.token-exists == 'true' }} permissions: contents: write continue-on-error: true