-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create action to disable specific worfklows based on repo config
Signed-off-by: Jose R. Gonzalez <komish@flutes.dev>
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Ensure CI is Enabled | ||
# This workflow allows a project to disable workflows based on a repository or | ||
# organizational environment variable. | ||
# | ||
# Create a repo or org environment variable with its value set to 'true' | ||
# for this workflow to succeed. Any other value should cause this workflow | ||
# to fail. | ||
# | ||
# https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository | ||
# | ||
# Example usage, assuming this workflow is local to your repository: | ||
# | ||
# jobs: | ||
# ensure_ci_enabled: | ||
# uses: ./.github/workflows/check-ci-enabled.yml | ||
# with: | ||
# is-enabled: ${{ vars.CUSTOM_VAR_CI_ENABLED }} | ||
# | ||
# next_task: | ||
# needs: ensure_ci_enabled | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - ... | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
is-enabled: | ||
type: string | ||
required: true | ||
|
||
jobs: | ||
fail_if_ci_disabled: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check enablement value | ||
run: | | ||
test "${{ inputs.is-enabled }}" = "true" \ | ||
|| { echo "::error::Halting because this repo/org/env configuration has not explicitly enabled this CI."; \ | ||
exit 1 ;} | ||
echo "::notice::CI is enabled!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Test CERTIFICATION_ENABLED | ||
|
||
# A developer convenience workflow. | ||
# Tests to see if the CERTIFICATION_ENABLED value indicates | ||
# certification is enabled. | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test_certification_enabled: | ||
uses: ./.github/workflows/ci-enabled.yml | ||
with: | ||
is-enabled: ${{ vars.CERTIFICATION_ENABLED }} |