Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
.github
_tests/fixtures
cmd
parser
printer
.gitignore
README.md
go.mod
go.sum
main.go

README.md

GITHUB WORKFLOW

Manage Github Action workflows and actions by cli. Allows you to script edition.

Available commands

  • github-workflow initialize

  • github-workflow lint

  • github-workflow workflow ls [ID][--on="pull_request"]

  • github-workflow workflow create ID ON [--resolve=]

  • github-workflow workflow add ID --resolve=

  • github-workflow workflow rename SOURCE TARGET

  • github-workflow workflow rm ID

  • github-workflow workflow merge ID [--on=]

  • github-workflow action ls [ID]

  • github-workflow action create ID USE [--env=<env_name>=<env_value> --secret=<secret_name>]

  • github-workflow action rename SOURCE TARGET

  • github-workflow action rm ID

Developing the github workflow

Getting it

You'll need a copy of go v1.11 or higher. Get binary directly from releases

  • Simple build, with latest versions of all dependencies: go get github.com/inextensodigital/actions/github-workflow

  • Repoducible build, using god mod to get pinned dependencies:

git clone get git@github.com:inextensodigital/actions.git
cd actions/github-workflow
go mod download
go build

Example for creating a new action on "pull_request" for many repositories

#!/usr/bin/env bash

github_username="your-organization"
action_name="Auto create master → dev PRs"
action_image="inextensodigital/actions/create-pull-request@master"
unified_workflow_name="On pull request"

for project in 'repo1' 'repo2' 'repo3'
do
    git clone --depth=1 --jobs=(sysctl -n hw.physicalcpu) "git@github.com:$github_username/$project.git" "/tmp/$project"
    cd "/tmp/$project"

    set -e
    set -o pipefail
    github-workflow initialize || echo "Workflow already initialized ✓"
    github-workflow action ls "$action_name" &> /dev/null || github-workflow action create "$action_name" "$action_image" --secret=GITHUB_TOKEN --env BASE=dev --env HEAD=master
    workflow_name=$(github-workflow workflow ls --on="pull_request" | head -n 1) && \
        ( \
            github-workflow workflow add "$workflow_name" --resolve "$action_name" && \
            github-workflow workflow rename "$workflow_name" "$unified_workflow_name" \
        ) \
    || \
        (
            github-workflow workflow ls "$unified_workflow_name" --on="pull_request" &> /dev/null || \
            github-workflow workflow create "$unified_workflow_name" "pull_request" --resolve="$action_name" \
        ) && \
    github-workflow lint

    git checkout -b chore-auto-create-master-dev-prs
    git add .

    if ! git diff-index --quiet HEAD --; then
        git commit -m "chore: $action_name" -m "Thanks to Github Actions"
        git push origin chore-auto-create-master-dev-prs
        hub pull-request -b $github_username:master -l enhancement -r reviewer_nickname -m "$action_name"
    fi

    cd /tmp && rm -rf "/tmp/$project"
done

Example of stdin usage

cat .github/stdin.workflow | github-workflow action ls
You can’t perform that action at this time.