cosmos-sdk/.github/actions/last-workflow-status/action.yaml
Julien Robert 748b9f08bc
ci: send slack alerts for sims only on status change (#12225)
* ci: send slack sims notification only on status change

Co-authored-by: Marko <marbar3778@yahoo.com>
2022-06-15 09:34:44 +02:00

37 lines
1.6 KiB
YAML

# from https://github.com/MercymeIlya/last-workflow-status with fixes
name: "Get status of last workflow"
description: "Get conclusion of last workflow run on current branch."
branding:
icon: "arrow-left"
color: "yellow"
inputs:
github_token:
description: Secret GitHub API token to use for making API requests.
default: ${{ github.token }}
required: true
outputs:
last_status:
description: "Conclusion of last workflow run on current branch"
value: ${{ steps.last_status.outputs.last_status }}
runs:
using: "composite"
steps:
- name: Get workflow id
shell: bash
run: |
WORKFLOW_ID=$(curl --header 'authorization: Bearer ${{ inputs.github_token }}' \
--header 'content-type: application/json' \
https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }} | jq -r .workflow_id)
echo "WORKFLOW_ID=$WORKFLOW_ID" >> $GITHUB_ENV
echo "Workflow id: ${WORKFLOW_ID}"
- name: Get previous build status
shell: bash
id: last_status
run: |
last_status=$(curl --silent --header 'authorization: Bearer ${{ inputs.github_token }}' \
--header 'content-type: application/json' \
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/${{ env.WORKFLOW_ID }}/runs?per_page=1&status=completed&branch=${{ env.GITHUB_HEAD_REF }}" \
| jq -r .workflow_runs[0].conclusion)
echo "Status of the previous build: $last_status"
echo "::set-output name=last_status::${last_status}"