Run a ok command #27
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 | |
permissions: | |
contents: read | |
pull-requests: write | |
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: Setup Homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
with: | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
- name: Install ok | |
env: | |
HOMEBREW_GITHUB_API_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
run: | | |
brew tap oslokommune/ok https://github.com/oslokommune/ok | |
brew update | |
brew install ok | |
ok "${{ inputs.subcommand }}" | |
- name: Run ls and git status | |
run: | | |
ls -la | |
git status | |
- if: inputs.create_pr | |
name: Import okctl-bot GPG key | |
id: gpg | |
uses: crazy-max/ghaction-import-gpg@82a020f1f7f605c65dd2449b392a52c3fcfef7ef # 6.0.0 | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
# Username and email is inferred from GPG key metadata | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
git_config_global: true | |
- if: inputs.create_pr | |
name: Create pull request (if changes) | |
id: pr | |
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2 | |
with: | |
title: | | |
chore: Run ok command `${{ inputs.subcommand}}` | |
body: | | |
Changes from running ok command `${{ inputs.subcommand }}`. | |
[Triggered by workflow run `${{ github.run_id }}` (click to see run)](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). | |
commit-message: | | |
chore: Run ok subcommand `${{ inputs.subcommand }}` | |
branch: "0-ok-${{ inputs.subcommand }}-${{ github.run_id }}" | |
delete-branch: true | |
author: "${{ steps.gpg.outputs.name }} <${{ steps.gpg.outputs.email }}>" | |
committer: "${{ steps.gpg.outputs.name }} <${{ steps.gpg.outputs.email }}>" |