Skip to content

Commit

Permalink
ci: update status of staging tests using GitHub REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
hhimanshu committed Apr 19, 2021
1 parent a3a8b24 commit aa91089
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion .github/workflows/preview-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,40 @@ jobs:
- name: Test
run: yarn test:integration --ci --coverage --maxWorkers=2
env:
STAGING_URL: ${{ github.event.deployment_status.target_url }}
STAGING_URL: ${{ github.event.deployment_status.target_url }}

# We must set the commit status manually
# Reference: https://github.com/bahmutov/eleventy-example/blob/main/.github/workflows/ci.yml#L27
- name: Staging Tests ✅
if: ${{ success() }}
# set the merge commit status check
# using GitHub REST API
# see https://docs.github.com/en/rest/reference/repos#create-a-commit-status
run: |
curl --request POST \
--url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"context": "Staging Tests",
"state": "success",
"description": "Staging tests passed",
"target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}'
- name: Staging Tests 🚨
if: ${{ failure() }}
# set the merge commit status check
# using GitHub REST API
# see https://docs.github.com/en/rest/reference/repos#create-a-commit-status
run: |
curl --request POST \
--url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"context": "Staging Tests",
"state": "failure",
"description": "Staging tests failed",
"target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}'

0 comments on commit aa91089

Please sign in to comment.