Skip to content

Instantly share code, notes, and snippets.

@theaccordance
Created July 10, 2020 17:43
Show Gist options
  • Save theaccordance/183f566b3ab41837523dfccf1661d132 to your computer and use it in GitHub Desktop.
Save theaccordance/183f566b3ab41837523dfccf1661d132 to your computer and use it in GitHub Desktop.
cut branch workflow
name: Create a release candidate branch
on:
schedule:
- cron: "45 9 * * 5" # Early Friday morning Central time (cron is UTC time!)
workflow_dispatch:
jobs:
create-release-candidate:
runs-on: ubuntu-latest
steps:
- name: Get branch name
id: get-branch-name
run: echo "::set-output name=branch-name::release/RC-$(date +'%Y-%m-%d')"
- name: Checkout 'master'
uses: actions/checkout@v2
with:
ref: "master"
- name: Configure git user name and email
run: |
git config --local user.email "[email protected]"
git config --local user.name "Bot"
- name: Check if RC branch already exists
id: branch-check
run: |
if [ -z "$(git ls-remote --heads origin ${{ steps.get-branch-name.outputs.branch-name }})" ]; then
echo "::set-output name=create-branch::yes"
fi
- name: Create RC branch
run: |
git checkout -b ${{ steps.get-branch-name.outputs.branch-name }}
git push --set-upstream origin \
${{ steps.get-branch-name.outputs.branch-name }}
git tag ${{ steps.get-branch-name.outputs.branch-name }}-001
git push --tags
if: steps.branch-check.outputs.create-branch == 'yes'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment