From ae1d21031978835822ad4ca1431c96e6170cd847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Fri, 6 Jan 2023 18:28:15 +0100 Subject: [PATCH] fix: condition jobs in gh actions (#5925) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché Signed-off-by: Charles-Edouard Brétéché --- .github/actions/is-defined/action.yaml | 21 +++++++++++++++++++++ .github/workflows/pr-update.yaml | 14 +++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .github/actions/is-defined/action.yaml diff --git a/.github/actions/is-defined/action.yaml b/.github/actions/is-defined/action.yaml new file mode 100644 index 0000000000..4f11f55633 --- /dev/null +++ b/.github/actions/is-defined/action.yaml @@ -0,0 +1,21 @@ +name: Checks if an input is defined + +description: Checks if an input is defined and outputs 'true' or 'false'. + +inputs: + value: + description: value to test + required: true + +outputs: + result: + description: outputs 'true' or 'false' if input value is defined or not + value: ${{ steps.check.outputs.result }} + +runs: + using: composite + steps: + - shell: bash + id: check + run: | + echo "result=${{ inputs.value != '' }}" >> $GITHUB_OUTPUT diff --git a/.github/workflows/pr-update.yaml b/.github/workflows/pr-update.yaml index 4cff14021b..525d310544 100644 --- a/.github/workflows/pr-update.yaml +++ b/.github/workflows/pr-update.yaml @@ -7,8 +7,20 @@ on: - 'release-*' jobs: + checksecret: + runs-on: ubuntu-latest + outputs: + result: ${{ steps.check.outputs.result }} + steps: + - name: Check secret + id: check + uses: ./.github/actions/is-defined + with: + value: ${{ secrets.PR_UPDATE_TOKEN }} + autoupdate: - if: ${{ secrets.PR_UPDATE_TOKEN }} + needs: [checksecret] + if: needs.checksecret.outputs.result == 'true' permissions: pull-requests: write runs-on: ubuntu-latest