From ab03b364f9484c4147a645e7bf36fa6c6981153c Mon Sep 17 00:00:00 2001 From: ZehuaCao <47251317+Romanticoseu@users.noreply.github.com> Date: Thu, 8 Sep 2022 10:18:03 +0800 Subject: [PATCH] add create-job-status-badge action (#5676) --- .../create-job-status-badge/action.yml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/actions/create-job-status-badge/action.yml diff --git a/.github/actions/create-job-status-badge/action.yml b/.github/actions/create-job-status-badge/action.yml new file mode 100644 index 00000000000..db8e1429f69 --- /dev/null +++ b/.github/actions/create-job-status-badge/action.yml @@ -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 }}