Skip to content

Commit

Permalink
Merge pull request openshift-helm-charts#249 from komish/add-cert-dis…
Browse files Browse the repository at this point in the history
…connect

Create action to disable specific workflows based on repo config
  • Loading branch information
komish authored Aug 9, 2023
2 parents 2780701 + 694a320 commit 6e7636b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ci-enabled.yml
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!"
14 changes: 14 additions & 0 deletions .github/workflows/test-ci-enabled.yml
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 }}

0 comments on commit 6e7636b

Please sign in to comment.