forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
36 lines (36 loc) · 1.56 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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}"