From 2aacf0ecaf7c3662a3ea598afb58994eacd37d38 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Wed, 12 Jun 2024 12:45:49 -0700 Subject: [PATCH] ci: Move set-commit-status custom action to shaka-github-tools repo --- .../set-commit-status/action.yaml | 59 ------------------- .github/workflows/selenium-lab-tests.yaml | 8 +-- .github/workflows/update-screenshots.yaml | 4 +- 3 files changed, 6 insertions(+), 65 deletions(-) delete mode 100644 .github/workflows/custom-actions/set-commit-status/action.yaml diff --git a/.github/workflows/custom-actions/set-commit-status/action.yaml b/.github/workflows/custom-actions/set-commit-status/action.yaml deleted file mode 100644 index 7b16edadf7b..00000000000 --- a/.github/workflows/custom-actions/set-commit-status/action.yaml +++ /dev/null @@ -1,59 +0,0 @@ -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" diff --git a/.github/workflows/selenium-lab-tests.yaml b/.github/workflows/selenium-lab-tests.yaml index bea324e480e..fc9ea97e7ba 100644 --- a/.github/workflows/selenium-lab-tests.yaml +++ b/.github/workflows/selenium-lab-tests.yaml @@ -150,7 +150,7 @@ jobs: - name: Set commit status to pending if: ${{ inputs.skip_test_status == false }} - uses: ./.github/workflows/custom-actions/set-commit-status + uses: shaka-project/shaka-github-tools/set-commit-status with: context: Selenium / Build job_name: "${{ inputs.job_name_prefix }}Pre-build Player" @@ -195,7 +195,7 @@ jobs: # Will run on success or failure, but not if the workflow is cancelled # or if we were asked to ignore the test status. if: ${{ (success() || failure()) && inputs.skip_commit_status == false }} - uses: ./.github/workflows/custom-actions/set-commit-status + uses: shaka-project/shaka-github-tools/set-commit-status with: context: Selenium / Build job_name: "${{ inputs.job_name_prefix }}Pre-build Player" @@ -220,7 +220,7 @@ jobs: - name: Set commit status to pending if: ${{ inputs.skip_commit_status == false }} - uses: ./.github/workflows/custom-actions/set-commit-status + uses: shaka-project/shaka-github-tools/set-commit-status with: context: Selenium / ${{ matrix.browser }} job_name: "${{ inputs.job_name_prefix }}${{ matrix.browser }}" @@ -378,7 +378,7 @@ jobs: # Will run on success or failure, but not if the workflow is cancelled # or if we were asked to ignore the test status. if: ${{ (success() || failure()) && inputs.skip_commit_status == false }} - uses: ./.github/workflows/custom-actions/set-commit-status + uses: shaka-project/shaka-github-tools/set-commit-status with: context: Selenium / ${{ matrix.browser }} job_name: "${{ inputs.job_name_prefix }}${{ matrix.browser }}" diff --git a/.github/workflows/update-screenshots.yaml b/.github/workflows/update-screenshots.yaml index 967ad931894..c02ce7a6be2 100644 --- a/.github/workflows/update-screenshots.yaml +++ b/.github/workflows/update-screenshots.yaml @@ -21,7 +21,7 @@ jobs: ref: refs/pull/${{ inputs.pr }}/head - name: Set commit status to pending - uses: ./.github/workflows/custom-actions/set-commit-status + uses: shaka-project/shaka-github-tools/set-commit-status with: context: Update All Screenshots state: pending @@ -122,7 +122,7 @@ jobs: fi - name: Report final status - uses: ./.github/workflows/custom-actions/set-commit-status + uses: shaka-project/shaka-github-tools/set-commit-status with: context: Update All Screenshots state: ${{ steps.compute.outputs.status }}