From a05ea20ef1107cc0a4ace94d6dffd7c7e590b264 Mon Sep 17 00:00:00 2001 From: Adin Scannell Date: Tue, 28 Jul 2020 09:39:08 -0700 Subject: [PATCH] Don't attempt to use the secret if it does not exist. Fixes #3326 PiperOrigin-RevId: 323589669 --- .github/workflows/go.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 10c86f5cd..a81d06cca 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -11,7 +11,13 @@ jobs: generate: runs-on: ubuntu-latest steps: - - run: | + - id: setup + run: | + if ! [[ -z "${{ secrets.GO_TOKEN }}" ]]; then + echo ::set-output has_token=true + else + echo ::set-output has_token=false + fi jq -nc '{"state": "pending", "context": "go tests"}' | \ curl -sL -X POST -d @- \ -H "Content-Type: application/json" \ @@ -19,12 +25,12 @@ jobs: "${{ github.event.pull_request.statuses_url }}" if: github.event_name == 'pull_request' - uses: actions/checkout@v2 - if: github.event_name == 'push' + if: github.event_name == 'push' && steps.setup.outputs.has_token == 'true' with: fetch-depth: 0 token: '${{ secrets.GO_TOKEN }}' - uses: actions/checkout@v2 - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request' || steps.setup.outputs.has_token != 'true' with: fetch-depth: 0 - uses: actions/setup-go@v2