Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add create-job-status-badge action #5676

Merged
merged 1 commit into from
Sep 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/actions/create-job-status-badge/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: 'Create Job Status Badge'
description: 'In a workflow with multiple jobs, create a badge that can display the completion time and status of the job'
inputs:
secret:
description: 'use to access gist'
required: true
gist-id:
description: 'gist-id'
required: true
file-name:
description: 'gist file name(.json)'
required: true
type:
description: 'workflow or job'
required: true
job-name:
description: 'job name'
runs:
using: "composite"
steps:
- name: print time
shell: bash
run: |
export NOW=$( date '+%F_%H:%M:%S' )
echo "TIME=${NOW}" >> $GITHUB_ENV
- name: get job status
shell: bash
run: |
echo "JOB-STATUS=${{ job.status }}" >>$GITHUB_ENV
- name: set badge color
shell: bash
run: if [ ${{ env.JOB-STATUS }} == "success" ] ; then echo "COLOR=green" >> $GITHUB_ENV ; else echo "COLOR=red" >> $GITHUB_ENV; fi

- name: Create job badge
if: ${{ inputs.type == 'job' }}
uses: analytics-zoo/dynamic-badges-action@master
with:
auth: ${{ inputs.secret }}
gistID: ${{ inputs.gist-id }}
filename: ${{ inputs.file-name }}
label: ${{ inputs.job-name }}
message: ${{ env.JOB-STATUS }}
color: ${{ env.COLOR }}

- name: Create time badge
if: ${{ inputs.type == 'workflow' }}
uses: analytics-zoo/dynamic-badges-action@master
with:
auth: ${{ inputs.secret }}
gistID: ${{ inputs.gist-id }}
filename: ${{ inputs.file-name }}
label: Time is
message: ${{ env.TIME }}