From ec5c63de06b27a65216b06dd55deba6f02e2ec32 Mon Sep 17 00:00:00 2001 From: Jesse Newland Date: Thu, 23 May 2024 16:57:19 +0000 Subject: [PATCH 01/14] add initial required workflow --- .github/required.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/required.yml diff --git a/.github/required.yml b/.github/required.yml new file mode 100644 index 0000000..879f91a --- /dev/null +++ b/.github/required.yml @@ -0,0 +1,29 @@ +# Create a Status named 'Required' that reports the observed conclusion of all +# WorkflowRuns with a name matching `/required/i` on the same `head_sha` as the +# observed WorkflowRun. +name: Required + +on: + workflow_run: + workflows: + - Check Transpiled JavaScript + - Continuous Integration + - Lint Codebase + types: + - completed + +jobs: + success: + if: github.event.workflow_run.event == 'pull_request' + name: Create appropriate status + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./ + with: + token: ${{ secrets.GITHUB_TOKEN }} + status-name: Required + must-succeed-if-run: | + Check Transpiled JavaScript + Continuous Integration + Lint Codebase From 1b71e50502212a672cf8c46224e1d832898ab49d Mon Sep 17 00:00:00 2001 From: Jesse Newland Date: Thu, 23 May 2024 16:58:44 +0000 Subject: [PATCH 02/14] merge group too --- .github/required.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/required.yml b/.github/required.yml index 879f91a..d0eb3c1 100644 --- a/.github/required.yml +++ b/.github/required.yml @@ -14,7 +14,7 @@ on: jobs: success: - if: github.event.workflow_run.event == 'pull_request' + if: contains(fromJSON('["merge_group", "pull_request"]'), github.event.workflow_run.event) name: Create appropriate status runs-on: ubuntu-latest steps: From a7de1d45fcf3fc6e924488479a27ff6f129d2f36 Mon Sep 17 00:00:00 2001 From: Jesse Newland Date: Thu, 23 May 2024 16:59:08 +0000 Subject: [PATCH 03/14] explain --- .github/required.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/required.yml b/.github/required.yml index d0eb3c1..60f66d3 100644 --- a/.github/required.yml +++ b/.github/required.yml @@ -1,6 +1,5 @@ # Create a Status named 'Required' that reports the observed conclusion of all -# WorkflowRuns with a name matching `/required/i` on the same `head_sha` as the -# observed WorkflowRun. +# matching WorkflowRuns on the same `head_sha` as the observed WorkflowRun. name: Required on: From ecb7e2286f984dc5843ca7747b789dc6ac289a0d Mon Sep 17 00:00:00 2001 From: Jesse Newland Date: Thu, 23 May 2024 17:01:21 +0000 Subject: [PATCH 04/14] update --- .github/required.yml | 4 +++- README.md | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/.github/required.yml b/.github/required.yml index 60f66d3..b6a1d43 100644 --- a/.github/required.yml +++ b/.github/required.yml @@ -13,7 +13,9 @@ on: jobs: success: - if: contains(fromJSON('["merge_group", "pull_request"]'), github.event.workflow_run.event) + if: + contains(fromJSON('["merge_group", "pull_request"]'), + github.event.workflow_run.event) name: Create appropriate status runs-on: ubuntu-latest steps: diff --git a/README.md b/README.md index 736f27b..e991f7b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,34 @@ # Required workflows Configure required workflows in your repository. Use path filters. Be free. + +## Usage + +``` +name: Required + +on: + workflow_run: + workflows: + - Check Transpiled JavaScript + - Continuous Integration + - Lint Codebase + types: + - completed + +jobs: + success: + if: contains(fromJSON('["merge_group", "pull_request"]'), github.event.workflow_run.event) + name: Create appropriate status + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./ + with: + token: ${{ secrets.GITHUB_TOKEN }} + status-name: Required + must-succeed-if-run: | + Check Transpiled JavaScript + Continuous Integration + Lint Codebase +``` From 4de53610c7240acf959f6d7fe71849d4ce973342 Mon Sep 17 00:00:00 2001 From: Jesse Newland Date: Thu, 23 May 2024 12:07:42 -0500 Subject: [PATCH 05/14] Delete .github/required.yml --- .github/required.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .github/required.yml diff --git a/.github/required.yml b/.github/required.yml deleted file mode 100644 index b6a1d43..0000000 --- a/.github/required.yml +++ /dev/null @@ -1,30 +0,0 @@ -# Create a Status named 'Required' that reports the observed conclusion of all -# matching WorkflowRuns on the same `head_sha` as the observed WorkflowRun. -name: Required - -on: - workflow_run: - workflows: - - Check Transpiled JavaScript - - Continuous Integration - - Lint Codebase - types: - - completed - -jobs: - success: - if: - contains(fromJSON('["merge_group", "pull_request"]'), - github.event.workflow_run.event) - name: Create appropriate status - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./ - with: - token: ${{ secrets.GITHUB_TOKEN }} - status-name: Required - must-succeed-if-run: | - Check Transpiled JavaScript - Continuous Integration - Lint Codebase From ec19c50fc9f9622939018827afc9ecb17139de9b Mon Sep 17 00:00:00 2001 From: Jesse Newland Date: Thu, 23 May 2024 13:16:11 -0500 Subject: [PATCH 06/14] Update README.md --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e991f7b..c9ef24d 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ # Required workflows -Configure required workflows in your repository. Use path filters. Be free. +Configure required workflows in your repository. Use path filters. Leave your GitHub org administrator alone. ## Usage -``` +- Add an workflow like the following: + +```yaml name: Required on: @@ -23,7 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: ./ + - uses: urcomputeringpal/required-workflows@v1 with: token: ${{ secrets.GITHUB_TOKEN }} status-name: Required @@ -32,3 +34,5 @@ jobs: Continuous Integration Lint Codebase ``` + +- Use `CODEOWNERS` to protect the contents of this file on your default branch From e2f2b48646989be1d3e798995c888ccd8bc8bd0a Mon Sep 17 00:00:00 2001 From: Jesse Newland Date: Thu, 23 May 2024 18:18:08 +0000 Subject: [PATCH 07/14] lol --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c9ef24d..03a92dc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Required workflows -Configure required workflows in your repository. Use path filters. Leave your GitHub org administrator alone. +Configure required workflows in your repository. Use path filters. Leave your +GitHub org administrator alone. ## Usage @@ -20,7 +21,9 @@ on: jobs: success: - if: contains(fromJSON('["merge_group", "pull_request"]'), github.event.workflow_run.event) + if: + contains(fromJSON('["merge_group", "pull_request"]'), + github.event.workflow_run.event) name: Create appropriate status runs-on: ubuntu-latest steps: From 41611e48b4e94bf457a4ca977cd1cbf1745ee9ea Mon Sep 17 00:00:00 2001 From: Jesse Newland Date: Thu, 23 May 2024 18:18:47 +0000 Subject: [PATCH 08/14] main for now --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 03a92dc..aafc798 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: urcomputeringpal/required-workflows@v1 + - uses: urcomputeringpal/required-workflows@main with: token: ${{ secrets.GITHUB_TOKEN }} status-name: Required From 3954b4a4f285e47b3930abe9c24b014a2d098169 Mon Sep 17 00:00:00 2001 From: Jesse Newland Date: Thu, 23 May 2024 18:27:19 +0000 Subject: [PATCH 09/14] cleanup --- .github/workflows/required.yml | 5 +++++ README.md | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/.github/workflows/required.yml b/.github/workflows/required.yml index 17b240f..5f262f2 100644 --- a/.github/workflows/required.yml +++ b/.github/workflows/required.yml @@ -11,6 +11,11 @@ on: types: - completed +permissions: + contents: read + actions: read + statuses: write + jobs: success: if: diff --git a/README.md b/README.md index aafc798..c12df8b 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,27 @@ -# Required workflows +# Optional Required workflows Configure required workflows in your repository. Use path filters. Leave your GitHub org administrator alone. -## Usage +Using this action to configuring required workflows in a GitHub Actions workflow +protected by a `CODEOWNERS` file instead of in your repository settings. + +## How it works + +- A workflow in your repository is created that called this Action +- This workflow contains a list of other workflows that are required to pass +- When any of those workflows complete on a PR, this workflow will check to see + if ANY of them are present on the same SHA +- If **all** of the matching observed on the same SHA **have passed**, this + workflow will create a success status +- If **any** of the listed workflows on the same SHA **have failed**, this + workflow will create a failure status +- If we're still waiting, a pending status will be created that reports what + we're waiting for +- If none of the listed workflows report a completed status via GitHub's API, + we'll refresh until we see a status + +## Setup - Add an workflow like the following: @@ -19,6 +37,11 @@ on: types: - completed +permissions: + contents: read + actions: read + statuses: write + jobs: success: if: @@ -26,9 +49,13 @@ jobs: github.event.workflow_run.event) name: Create appropriate status runs-on: ubuntu-latest + permissions: + contents: read + actions: read + statuses: write steps: - uses: actions/checkout@v3 - - uses: urcomputeringpal/required-workflows@main + - uses: urcomputeringpal/optional-required-workflows@main with: token: ${{ secrets.GITHUB_TOKEN }} status-name: Required @@ -39,3 +66,4 @@ jobs: ``` - Use `CODEOWNERS` to protect the contents of this file on your default branch +- Mark the 'Required' build as required in your repository settings From 0ba22d7babdafc03956ccc792d63ad569c120c58 Mon Sep 17 00:00:00 2001 From: Jesse Newland Date: Thu, 23 May 2024 18:32:06 +0000 Subject: [PATCH 10/14] clarify --- .github/workflows/required.yml | 6 +++++- README.md | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/required.yml b/.github/workflows/required.yml index 5f262f2..2240493 100644 --- a/.github/workflows/required.yml +++ b/.github/workflows/required.yml @@ -16,12 +16,16 @@ permissions: actions: read statuses: write +run-name: > + Process ${{ github.event.workflow_run.conclusion }} of ${{ + github.event.workflow_run.name }} + jobs: success: if: contains(fromJSON('["merge_group", "pull_request"]'), github.event.workflow_run.event) - name: Create appropriate status + name: Check required workflow status runs-on: ubuntu-latest permissions: contents: read diff --git a/README.md b/README.md index c12df8b..1fd9f11 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ jobs: if: contains(fromJSON('["merge_group", "pull_request"]'), github.event.workflow_run.event) - name: Create appropriate status + name: Check required workflow status runs-on: ubuntu-latest permissions: contents: read From 9371acbb566e7cad622151e7c0f3e07b938e6b77 Mon Sep 17 00:00:00 2001 From: Jesse Newland Date: Thu, 23 May 2024 18:33:16 +0000 Subject: [PATCH 11/14] docs --- README.md | 4 ++-- action.yml | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1fd9f11..8848bf7 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ Configure required workflows in your repository. Use path filters. Leave your GitHub org administrator alone. -Using this action to configuring required workflows in a GitHub Actions workflow -protected by a `CODEOWNERS` file instead of in your repository settings. +Use this Action to configuring required workflows in a workflow file protected +by `CODEOWNERS` in your repository instead of in your repository settings. ## How it works diff --git a/action.yml b/action.yml index f1f8ebc..db8bff8 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,7 @@ name: Required workflows description: >- - Configure required workflows in your repo. Use path filters. Be free. + Configure required workflows in your repository. Use path filters. + Leave your GitHub org administrator alone. author: jnewland@urcomputeringpal.com # Add your action's branding here. This will appear on the GitHub Marketplace. branding: From a370de2c64d7e04310a9e578bc9db204c097cff9 Mon Sep 17 00:00:00 2001 From: Jesse Newland Date: Thu, 23 May 2024 18:35:12 +0000 Subject: [PATCH 12/14] k --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index db8bff8..1c8c110 100644 --- a/action.yml +++ b/action.yml @@ -1,7 +1,7 @@ name: Required workflows description: >- - Configure required workflows in your repository. Use path filters. - Leave your GitHub org administrator alone. + Configure required workflows in your repository. Use path filters. Leave your + GitHub org administrator alone. author: jnewland@urcomputeringpal.com # Add your action's branding here. This will appear on the GitHub Marketplace. branding: From 2f4a82d3a9c09797415741e64ccf4f418639bd0f Mon Sep 17 00:00:00 2001 From: Jesse Newland Date: Thu, 23 May 2024 18:39:08 +0000 Subject: [PATCH 13/14] clean --- README.md | 12 ++++++++---- action.yml | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8848bf7..2f7fa33 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Optional Required workflows +# Optional required workflows Configure required workflows in your repository. Use path filters. Leave your GitHub org administrator alone. @@ -8,13 +8,17 @@ by `CODEOWNERS` in your repository instead of in your repository settings. ## How it works -- A workflow in your repository is created that called this Action +- A workflow in your repository is created that calls this Action - This workflow contains a list of other workflows that are required to pass - When any of those workflows complete on a PR, this workflow will check to see if ANY of them are present on the same SHA -- If **all** of the matching observed on the same SHA **have passed**, this +- If **all** of the matching workflows on the same SHA **have passed**, this workflow will create a success status -- If **any** of the listed workflows on the same SHA **have failed**, this +- If **any** of the matching workflows on the same SHA **are missing**, this + workflow **will still create a success status** + - This allows you to use path filters to skip certain workflows on certain + paths and still mark them as required. +- If **any** of the matching workflows on the same SHA **have failed**, this workflow will create a failure status - If we're still waiting, a pending status will be created that reports what we're waiting for diff --git a/action.yml b/action.yml index 1c8c110..ca6bcac 100644 --- a/action.yml +++ b/action.yml @@ -1,4 +1,4 @@ -name: Required workflows +name: Optional required workflows description: >- Configure required workflows in your repository. Use path filters. Leave your GitHub org administrator alone. From 619457033fa703ddbd764a82b3834b7b7607314e Mon Sep 17 00:00:00 2001 From: Jesse Newland Date: Thu, 23 May 2024 18:39:49 +0000 Subject: [PATCH 14/14] modern --- .github/workflows/required.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/required.yml b/.github/workflows/required.yml index 2240493..136c0e8 100644 --- a/.github/workflows/required.yml +++ b/.github/workflows/required.yml @@ -32,7 +32,7 @@ jobs: actions: read statuses: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ./ with: token: ${{ secrets.GITHUB_TOKEN }}