Skip to content

Changes from CMS

Changes from CMS #77

name: Create Review Branch for Drafts Review
on:
workflow_dispatch:
inputs:
branch_name:
description: 'Name of the branch to create (e.g., review)'
required: true
default: 'review'
push:
branches:
- main
permissions:
contents: write
jobs:
create_branch:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: 'main'
- name: Configure Git
run: |
git config user.name "GitHub Actions"
git config user.email "github-actions@github.com"
- name: Determine Branch Name
id: set_branch_name
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_BRANCH: ${{ github.event.inputs.branch_name }}
run: |
if [ "$EVENT_NAME" == "workflow_dispatch" ]; then
echo "BRANCH_NAME=$INPUT_BRANCH" >> "$GITHUB_OUTPUT"
else
echo "BRANCH_NAME=review" >> "$GITHUB_OUTPUT"
fi
- name: Delete existing review branch (if it exists)
env:
BRANCH_NAME: ${{ steps.set_branch_name.outputs.BRANCH_NAME }}
run: |
git push origin --delete "$BRANCH_NAME" || true
- name: Create new review branch from main
env:
BRANCH_NAME: ${{ steps.set_branch_name.outputs.BRANCH_NAME }}
run: |
git checkout -b "$BRANCH_NAME"
git push origin "$BRANCH_NAME"
- name: Trigger Netlify Deploy (Optional)
env:
NETLIFY_PREVIEW_BUILD_HOOK: ${{ secrets.NETLIFY_PREVIEW_BUILD_HOOK }}
run: |
if test -n "$NETLIFY_PREVIEW_BUILD_HOOK"; then
echo "Triggering Netlify deploy for preview branch..."
curl -X POST -d '{}' "$NETLIFY_PREVIEW_BUILD_HOOK"
else
echo "NETLIFY_PREVIEW_BUILD_HOOK secret is not set or empty. Skipping Netlify deploy trigger."
fi