From b6da961323eeb038ab79a73387155727c3aee8d0 Mon Sep 17 00:00:00 2001 From: Nuru Date: Fri, 30 Sep 2022 16:30:41 -0700 Subject: [PATCH] Use args with status updater instead of env vars, update checkout to v3 (#133) --- .github/workflows/test-command.yml | 215 ++++++++++++++++------------- 1 file changed, 122 insertions(+), 93 deletions(-) diff --git a/.github/workflows/test-command.yml b/.github/workflows/test-command.yml index 4b345625..6b28d8d6 100644 --- a/.github/workflows/test-command.yml +++ b/.github/workflows/test-command.yml @@ -72,19 +72,23 @@ jobs: if: needs.parse.outputs.run-ping == 'true' steps: # Update GitHub status for dispatch events + # Use command line args because GitHub actions reserves `GITHUB_*` environment variables - name: "Update GitHub Status for this ref" #if: ${{ github.event_name == 'repository_dispatch' }} uses: 'docker://cloudposse/github-status-updater' with: # We need to use args because GitHub actions overwrites many `GITHUB_*` environment variables - args: "-action update_state -ref ${{ github.event.client_payload.pull_request.head.sha }} -repo ${{ github.event.client_payload.github.payload.repository.name }}" + args: >- + -action update_state + -ref "${{ github.event.client_payload.pull_request.head.sha }}" + -repo "${{ github.event.client_payload.github.payload.repository.name }}" + -state success + -context "test/ping" + -description pong + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + -owner "${{ github.event.client_payload.github.payload.repository.owner.login }}" env: GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} - GITHUB_STATE: success - GITHUB_CONTEXT: 'test/ping' - GITHUB_DESCRIPTION: "pong" - GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login }} readme: runs-on: ubuntu-latest @@ -95,23 +99,26 @@ jobs: MAKE_INCLUDES: Makefile steps: # Update GitHub status for dispatch events + # Use command line args because GitHub actions reserves `GITHUB_*` environment variables - name: "Update GitHub Status for pending" uses: docker://cloudposse/github-status-updater with: - args: "-action update_state -ref ${{ github.event.client_payload.pull_request.head.sha }} -repo ${{ github.event.client_payload.github.payload.repository.name }}" + args: >- + -action update_state + -ref "${{ github.event.client_payload.pull_request.head.sha }}" + -repo "${{ github.event.client_payload.github.payload.repository.name }}" + -state pending + -context "test/readme" + -description "Tests started by @${{ github.event.client_payload.github.actor }}" + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + -owner "${{ github.event.client_payload.github.payload.repository.owner.login }}" env: GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} - GITHUB_STATE: pending - GITHUB_CONTEXT: "test/readme" - GITHUB_DESCRIPTION: "tests started by @${{ github.event.client_payload.github.actor }}" - GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - GITHUB_REF: ${{ github.event.client_payload.pull_request.head.ref }} - GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login }} # Checkout the code from GitHub Pull Request - name: "Checkout code for ChatOps" - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} @@ -132,44 +139,50 @@ jobs: if: ${{ failure() }} uses: docker://cloudposse/github-status-updater with: - args: "-action update_state -ref ${{ github.event.client_payload.pull_request.head.sha }} -repo ${{ github.event.client_payload.github.payload.repository.name }}" + args: >- + -action update_state + -ref "${{ github.event.client_payload.pull_request.head.sha }}" + -repo "${{ github.event.client_payload.github.payload.repository.name }}" + -state failure + -context "test/readme" + -description "Tests failed" + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + -owner "${{ github.event.client_payload.github.payload.repository.owner.login }}" env: GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} - GITHUB_STATE: failure - GITHUB_CONTEXT: "test/readme" - GITHUB_DESCRIPTION: "tests failed" - GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - GITHUB_REF: ${{ github.event.client_payload.pull_request.head.ref }} - GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login }} # Update GitHub status for dispatch events - name: "Update GitHub Status for success" uses: docker://cloudposse/github-status-updater with: - args: "-action update_state -ref ${{ github.event.client_payload.pull_request.head.sha }} -repo ${{ github.event.client_payload.github.payload.repository.name }}" + args: >- + -action update_state + -ref "${{ github.event.client_payload.pull_request.head.sha }}" + -repo "${{ github.event.client_payload.github.payload.repository.name }}" + -state success + -context "test/readme" + -description "Tests passed" + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + -owner "${{ github.event.client_payload.github.payload.repository.owner.login }}" env: GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} - GITHUB_STATE: success - GITHUB_CONTEXT: "test/readme" - GITHUB_DESCRIPTION: "tests passed" - GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - GITHUB_REF: ${{ github.event.client_payload.pull_request.head.ref }} - GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login }} # Update GitHub status for dispatch events - name: "Update GitHub Status for cancelled" if: ${{ cancelled() }} uses: docker://cloudposse/github-status-updater with: - args: "-action update_state -ref ${{ github.event.client_payload.pull_request.head.sha }} -repo ${{ github.event.client_payload.github.payload.repository.name }}" + args: >- + -action update_state + -ref "${{ github.event.client_payload.pull_request.head.sha }}" + -repo "${{ github.event.client_payload.github.payload.repository.name }}" + -state error + -context "test/readme" + -description "Tests cancelled" + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + -owner "${{ github.event.client_payload.github.payload.repository.owner.login }}" env: GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} - GITHUB_STATE: error - GITHUB_CONTEXT: "test/readme" - GITHUB_DESCRIPTION: "tests cancelled" - GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - GITHUB_REF: ${{ github.event.client_payload.pull_request.head.ref }} - GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login }} bats: runs-on: ubuntu-latest @@ -184,19 +197,21 @@ jobs: - name: "Update GitHub Status for pending" uses: docker://cloudposse/github-status-updater with: - args: "-action update_state -ref ${{ github.event.client_payload.pull_request.head.sha }} -repo ${{ github.event.client_payload.github.payload.repository.name }}" + args: >- + -action update_state + -ref "${{ github.event.client_payload.pull_request.head.sha }}" + -repo "${{ github.event.client_payload.github.payload.repository.name }}" + -state pending + -context "test/bats" + -description "Tests started by @${{ github.event.client_payload.github.actor }}" + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + -owner "${{ github.event.client_payload.github.payload.repository.owner.login }}" env: GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} - GITHUB_STATE: pending - GITHUB_CONTEXT: "test/bats" - GITHUB_DESCRIPTION: "tests started by @${{ github.event.client_payload.github.actor }}" - GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - GITHUB_REF: ${{ github.event.client_payload.pull_request.head.ref }} - GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login }} # Checkout the code from GitHub Pull Request - name: "Checkout code for ChatOps" - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} @@ -265,44 +280,50 @@ jobs: if: ${{ failure() }} uses: docker://cloudposse/github-status-updater with: - args: "-action update_state -ref ${{ github.event.client_payload.pull_request.head.sha }} -repo ${{ github.event.client_payload.github.payload.repository.name }}" + args: >- + -action update_state + -ref "${{ github.event.client_payload.pull_request.head.sha }}" + -repo "${{ github.event.client_payload.github.payload.repository.name }}" + -state failure + -context "test/bats" + -description "Tests failed" + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + -owner "${{ github.event.client_payload.github.payload.repository.owner.login }}" env: GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} - GITHUB_STATE: failure - GITHUB_CONTEXT: "test/bats" - GITHUB_DESCRIPTION: "tests failed" - GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - GITHUB_REF: ${{ github.event.client_payload.pull_request.head.ref }} - GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login }} # Update GitHub status for dispatch events - name: "Update GitHub Status for success" uses: docker://cloudposse/github-status-updater with: - args: "-action update_state -ref ${{ github.event.client_payload.pull_request.head.sha }} -repo ${{ github.event.client_payload.github.payload.repository.name }}" + args: >- + -action update_state + -ref "${{ github.event.client_payload.pull_request.head.sha }}" + -repo "${{ github.event.client_payload.github.payload.repository.name }}" + -state success + -context "test/bats" + -description "Tests passed" + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + -owner "${{ github.event.client_payload.github.payload.repository.owner.login }}" env: GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} - GITHUB_STATE: success - GITHUB_CONTEXT: "test/bats" - GITHUB_DESCRIPTION: "tests passed" - GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - GITHUB_REF: ${{ github.event.client_payload.pull_request.head.ref }} - GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login }} # Update GitHub status for dispatch events - name: "Update GitHub Status for cancelled" if: ${{ cancelled() }} uses: docker://cloudposse/github-status-updater with: - args: "-action update_state -ref ${{ github.event.client_payload.pull_request.head.sha }} -repo ${{ github.event.client_payload.github.payload.repository.name }}" + args: >- + -action update_state + -ref "${{ github.event.client_payload.pull_request.head.sha }}" + -repo "${{ github.event.client_payload.github.payload.repository.name }}" + -state error + -context "test/bats" + -description "Tests cancelled" + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + -owner "${{ github.event.client_payload.github.payload.repository.owner.login }}" env: GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} - GITHUB_STATE: error - GITHUB_CONTEXT: "test/bats" - GITHUB_DESCRIPTION: "tests cancelled" - GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - GITHUB_REF: ${{ github.event.client_payload.pull_request.head.ref }} - GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login }} terratest: runs-on: ubuntu-latest @@ -316,19 +337,21 @@ jobs: - name: "Update GitHub Status for pending" uses: docker://cloudposse/github-status-updater with: - args: "-action update_state -ref ${{ github.event.client_payload.pull_request.head.sha }} -repo ${{ github.event.client_payload.github.payload.repository.name }}" + args: >- + -action update_state + -ref "${{ github.event.client_payload.pull_request.head.sha }}" + -repo "${{ github.event.client_payload.github.payload.repository.name }}" + -state pending + -context "test/terratest" + -description "Tests started by @${{ github.event.client_payload.github.actor }}" + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + -owner "${{ github.event.client_payload.github.payload.repository.owner.login }}" env: GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} - GITHUB_STATE: pending - GITHUB_CONTEXT: "test/terratest" - GITHUB_DESCRIPTION: "tests started by @${{ github.event.client_payload.github.actor }}" - GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - GITHUB_REF: ${{ github.event.client_payload.pull_request.head.ref }} - GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login }} # Checkout the code from GitHub Pull Request - name: "Checkout code for ChatOps" - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} @@ -460,42 +483,48 @@ jobs: if: ${{ failure() }} uses: docker://cloudposse/github-status-updater with: - args: "-action update_state -ref ${{ github.event.client_payload.pull_request.head.sha }} -repo ${{ github.event.client_payload.github.payload.repository.name }}" + args: >- + -action update_state + -ref "${{ github.event.client_payload.pull_request.head.sha }}" + -repo "${{ github.event.client_payload.github.payload.repository.name }}" + -state failure + -context "test/terratest" + -description "Tests failed" + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + -owner "${{ github.event.client_payload.github.payload.repository.owner.login }}" env: GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} - GITHUB_STATE: failure - GITHUB_CONTEXT: "test/terratest" - GITHUB_DESCRIPTION: "tests failed" - GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - GITHUB_REF: ${{ github.event.client_payload.pull_request.head.ref }} - GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login }} # Update GitHub status for dispatch events - name: "Update GitHub Status for this success" uses: docker://cloudposse/github-status-updater with: - args: "-action update_state -ref ${{ github.event.client_payload.pull_request.head.sha }} -repo ${{ github.event.client_payload.github.payload.repository.name }}" + args: >- + -action update_state + -ref "${{ github.event.client_payload.pull_request.head.sha }}" + -repo "${{ github.event.client_payload.github.payload.repository.name }}" + -state success + -context "test/terratest" + -description "Tests passed" + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + -owner "${{ github.event.client_payload.github.payload.repository.owner.login }}" env: GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} - GITHUB_STATE: success - GITHUB_CONTEXT: "test/terratest" - GITHUB_DESCRIPTION: "tests passed" - GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - GITHUB_REF: ${{ github.event.client_payload.pull_request.head.ref }} - GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login }} # Update GitHub status for dispatch events - name: "Update GitHub Status for cancelled" if: ${{ cancelled() }} uses: docker://cloudposse/github-status-updater with: - args: "-action update_state -ref ${{ github.event.client_payload.pull_request.head.sha }} -repo ${{ github.event.client_payload.github.payload.repository.name }}" + args: >- + -action update_state + -ref "${{ github.event.client_payload.pull_request.head.sha }}" + -repo "${{ github.event.client_payload.github.payload.repository.name }}" + -state error + -context "test/terratest" + -description "Tests cancelled" + -url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + -owner "${{ github.event.client_payload.github.payload.repository.owner.login }}" env: GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} - GITHUB_STATE: error - GITHUB_CONTEXT: "test/terratest" - GITHUB_DESCRIPTION: "tests cancelled" - GITHUB_TARGET_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - GITHUB_REF: ${{ github.event.client_payload.pull_request.head.ref }} - GITHUB_OWNER: ${{ github.event.client_payload.github.payload.repository.owner.login }}