mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-07-02 18:49:36 +03:00
7c00ac42a0
- Link CI status to specific jobs, not just the run - Split selenium job status flag away from ignore_test_status (which is for getting screenshots) - Remove redundant status setting step in update-screenshots - Fix final status computation in update-screenshots to account for edge cases and old typo
60 lines
2.3 KiB
YAML
60 lines
2.3 KiB
YAML
name: Set Commit Status
|
|
|
|
description: |
|
|
A reusable action that sets the commit status. This is used to set PR status
|
|
from workflows with non-PR triggers (such as manually-triggered workflows).
|
|
|
|
inputs:
|
|
context:
|
|
description: An arbitrary string to identify the status check.
|
|
required: true
|
|
state:
|
|
description: Either "pending", "error", "success", or "failure".
|
|
required: true
|
|
token:
|
|
description: A GitHub access token.
|
|
required: true
|
|
job_name:
|
|
description: A job name, so that the status' target URL can point to a specific job.
|
|
required: false
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Report Commit Status
|
|
shell: bash
|
|
run: |
|
|
export GITHUB_TOKEN="${{ inputs.token }}"
|
|
|
|
# Here we compute a "target URL". It will be attached to the commit
|
|
# status, so that when someone clicks "details" next to the status on
|
|
# the PR, it will link to the appropriate logs.
|
|
if [[ "${{ inputs.job_name }}" != "" ]]; then
|
|
# There are three identifiers for the job:
|
|
# - The job's key in YAML, which is "github.job"
|
|
# - The job's name, which is not provided by any runner environment
|
|
# - The job's numerical ID, which is not provided either
|
|
# To link to this specific job in the status, we need the numerical
|
|
# job ID. The GH API provides a list of jobs, which contain
|
|
# numerical IDs and names, but not keys. So the caller of this
|
|
# action must provide the string name, and then we look up the
|
|
# numerical ID in the API. "github.job" is useless here.
|
|
job_id=$(
|
|
gh api /repos/${{github.repository}}/actions/runs/${{github.run_id}}/jobs \
|
|
| jq '.jobs | map(select(.name=="${{ inputs.job_name }}")) | .[].id'
|
|
)
|
|
TARGET_URL="https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}/job/$job_id"
|
|
else
|
|
# Generic link to the run, without any specific job.
|
|
TARGET_URL="https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
|
|
fi
|
|
|
|
SHA1=$(git rev-parse HEAD)
|
|
|
|
gh api \
|
|
-X POST \
|
|
-F "context=${{ inputs.context }}" \
|
|
-F "state=${{ inputs.state }}" \
|
|
-F "target_url=$TARGET_URL" \
|
|
"repos/${{ github.repository }}/statuses/$SHA1"
|