Run a ok command #16
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
name: Run a ok command | |
on: | |
workflow_dispatch: | |
inputs: | |
subcommand: | |
type: choice | |
description: 'The ok command to run' | |
options: | |
- 'env' | |
- 'bootstrap' | |
- 'scaffold' | |
working_directory: | |
description: > | |
The working directory to run ok from. | |
required: true | |
type: string | |
create_pr: | |
type: boolean | |
description: 'Create a PR with the changes' | |
default: false | |
workflow_call: | |
secrets: | |
GPG_PRIVATE_KEY: | |
description: "The GPG private key to use for signing commits" | |
required: true | |
GPG_PASSPHRASE: | |
description: "The passphrase for the GPG private key" | |
required: true | |
inputs: | |
subcommand: | |
type: string | |
description: 'The ok command to run' | |
required: true | |
create_pr: | |
type: boolean | |
description: 'Create a PR with the changes' | |
default: false | |
jobs: | |
mage: | |
name: "Run ok subcommand ${{ inputs.subcommand }}" | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- name: Set up Go | |
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | |
with: | |
go-version-file: "go.mod" | |
cache-dependency-path: "go.sum" | |
- name: Setup mocks | |
run: | | |
function setupMocks() { | |
if ! command -v terraform &> /dev/null; then | |
function terraform() { | |
printf "mock terraform with args: %s\n" "${ARRAY_VAR[@]}" | |
} | |
export -f terraform | |
else | |
_ORIGINAL_TERRAFORM=$(which terraform) | |
fi | |
if ! command -v fzf &> /dev/null; then | |
function fzf() { | |
printf "mock fzf with args: %s\n" "${ARRAY_VAR[@]}" | |
} | |
export -f fzf | |
else | |
_ORIGINAL_FZF=$(which fzf) | |
fi | |
if ! command -v gh &> /dev/null; then | |
function gh() { | |
printf "mock gh with args: %s\n" "${ARRAY_VAR[@]}" | |
} | |
export -f gh | |
else | |
_ORIGINAL_GH=$(which gh) | |
fi | |
- name: Run ok | |
run: | | |
setupMocks | |
go run main.go "${{ inputs.subcommand }}" |