From 7eec009f410bdd6af7ba394ea4ef39d937259c1a Mon Sep 17 00:00:00 2001 From: Matt Bishop Date: Tue, 13 Aug 2024 15:05:50 -0400 Subject: [PATCH] Check for secrets before using them (#167) * Check for secrets before using them * Test all the appropriate branches --- .github/workflows/test.yml | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aa4a04f..a8a95d3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,17 +1,42 @@ -name: Test +name: Testing on: workflow_dispatch: push: branches: - "main" + - "rc" + - "hotfix-rc" pull_request: jobs: - test: + check-test-secrets: + name: Check for test secrets + runs-on: ubuntu-22.04 + outputs: + available: ${{ steps.check-test-secrets.outputs.available }} + permissions: + contents: read + + steps: + - name: Check + id: check-test-secrets + run: | + if [ "${{ secrets.CODECOV_TOKEN }}" != '' ]; then + echo "available=true" >> $GITHUB_OUTPUT; + else + echo "available=false" >> $GITHUB_OUTPUT; + fi + + testing: name: Run tests if: ${{ startsWith(github.head_ref, 'version_bump_') == false }} runs-on: ubuntu-22.04 + needs: check-test-secrets + permissions: + checks: write + contents: read + pull-requests: write steps: - name: Check out repo @@ -25,7 +50,7 @@ jobs: - name: Report test results uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 # v1.9.1 - if: always() + if: ${{ needs.check-test-secrets.outputs.available == 'true' && !cancelled() }} with: name: Test Results path: "**/test-results.trx" @@ -34,5 +59,6 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 + if: ${{ needs.check-test-secrets.outputs.available == 'true' }} env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}