Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github/branch/create action #194

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions github/branch/create/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Create GitHub branch"
description: "Create a unique branch for running GHA workflows, primarily for release pipelines"

inputs:
branch-group:
description: "Group to use for naming the branch with format <branch-group>/<current-date>/<run-id> (e.g. prep-release, nightly-release, etc.)"
default: "temp"

outputs:
branch:
description: "Name of the newly created branch"
value: ${{ steps.branch.outputs.name }}

runs:
using: composite
steps:
- name: "[DEBUG] Inputs"
shell: bash
run: |
echo "==========INPUTS=========="
echo branch-stub : ${{ inputs.branch-stub }}

- name: "Create branch"
id: branch
shell: bash
run: ./github/branch/create/create_branch.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also just a wrapper for a pretty simple bash script. It just makes determining what's happening harder.

env:
STUB: ${{ inputs.branch-group }}

- name: "[INFO] Create GitHub branch"
shell: bash
run: echo "::notice title=$TITLE::$MESSAGE"
env:
TITLE: "[${{ env.NOTIFICATION_PREFIX }}]: Create GitHub branch"
MESSAGE: "Created `${{ steps.branch.outputs.name }}`"

- name: "[DEBUG] Outputs"
shell: bash
run: |
echo "==========OUTPUTS=========="
echo branch : ${{ steps.branch.outputs.name }}
4 changes: 4 additions & 0 deletions github/branch/create/create_branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BRANCH="$STUB/$(date +'%Y-%m-%d')/$GITHUB_RUN_ID"
echo "name=$BRANCH" >> $GITHUB_OUTPUT
git checkout -b $BRANCH
git push -u origin $BRANCH