Skip to content

Commit

Permalink
Use args with status updater instead of env vars, update checkout to …
Browse files Browse the repository at this point in the history
…v3 (#133)
  • Loading branch information
Nuru authored Sep 30, 2022
1 parent 23d15dc commit b6da961
Showing 1 changed file with 122 additions and 93 deletions.
215 changes: 122 additions & 93 deletions .github/workflows/test-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -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
Expand All @@ -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 }}
Expand Down Expand Up @@ -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
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}

0 comments on commit b6da961

Please sign in to comment.