Skip to content

Update branch.yaml

Update branch.yaml #3

Workflow file for this run

name: Create Branch if Not Present
on:
push:
branches:
- main # Change this to your base branch
jobs:
create-branch:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Check if branch exists
id: check-branch
run: |
BRANCH_NAME=main # Change this to the branch you want to create
API_URL="https://api.github.com/repos/${{ github.repository }}/branches/${BRANCH_NAME}"
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" "$API_URL")
echo "::set-output name=branch_exists::$(if [ $RESPONSE -eq 200 ]; then echo 'true'; else echo 'false'; fi)"
- name: Create branch if not present
if: steps.check-branch.outputs.branch_exists == 'false'
run: |
BRANCH_NAME=main # Change this to the branch you want to create
git checkout -b $BRANCH_NAME
git push origin $BRANCH_NAME