From d2c32bbdb8e91690865169f98c6ef7e2ed672df2 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Wed, 6 Nov 2024 17:41:47 +0200 Subject: [PATCH] fix(ci): Skip e2e metrics steps when the auth token is not available (#4233) --- .github/workflows/e2e.yml | 7 +++++-- .github/workflows/skip-ci-noauth.yml | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/skip-ci-noauth.yml diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index b423a356c3..b002b9a897 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -20,11 +20,14 @@ env: jobs: diff_check: uses: ./.github/workflows/skip-ci.yml + auth_token_check: + uses: ./.github/workflows/skip-ci-noauth.yml + secrets: inherit metrics: runs-on: ${{ matrix.runs-on }} - needs: [diff_check] - if: ${{ needs.diff_check.outputs.skip_ci != 'true' && env.SENTRY_AUTH_TOKEN != null }} + needs: [diff_check, auth_token_check] + if: ${{ needs.diff_check.outputs.skip_ci != 'true' && needs.auth_token_check.outputs.skip_ci != 'true' }} env: SENTRY_DISABLE_AUTO_UPLOAD: 'true' strategy: diff --git a/.github/workflows/skip-ci-noauth.yml b/.github/workflows/skip-ci-noauth.yml new file mode 100644 index 0000000000..8b22d6325b --- /dev/null +++ b/.github/workflows/skip-ci-noauth.yml @@ -0,0 +1,25 @@ +name: Skip CI when the auth token is not accessible + +on: + workflow_call: + outputs: + skip_ci: + description: "Value 'true' if the CI cannot access the SENTRY_AUTH_TOKEN, otherwise, not defined." + value: ${{ jobs.auth_token_check.outputs.skip_ci }} + +jobs: + auth_token_check: + runs-on: ubuntu-latest + env: + sentry_auth_token: ${{ secrets.SENTRY_AUTH_TOKEN }} + outputs: + skip_ci: ${{ steps.set_skip_ci.outputs.skip_ci }} + steps: + - id: set_skip_ci + if: ${{ env.sentry_auth_token == '' }} + run: | + echo "skip_ci=true" >> $GITHUB_OUTPUT + echo "Cannot access SENTRY_AUTH_TOKEN, skipping CI." + + - if: ${{ env.sentry_auth_token != '' }} + run: echo "SENTRY_AUTH_TOKEN is accessible, continuing the CI checks."