Skip to content

Add branch to staging config #7

Add branch to staging config

Add branch to staging config #7

Workflow file for this run

name: Add branch to staging config
on:
workflow_dispatch:
inputs:
file:
description: 'Staging config file (e.g. commcare-hq-staging.yml)'
required: true
type: string
branch:
description: 'Branch name to add'
required: true
type: string
comment:
description: 'Comment after `#` on the branch line (defaults to e.g. `@dannyroberts Apr 29`)'
required: false
type: string
jobs:
add-branch:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
env:
FILE: ${{ inputs.file }}
BRANCH: ${{ inputs.branch }}
COMMENT: ${{ inputs.comment }}
ACTOR: ${{ github.actor }}
steps:
- uses: actions/checkout@v6
with:
ref: main
- uses: astral-sh/setup-uv@v6
- name: Add branch to config
run: |
if [ -z "$COMMENT" ]; then
COMMENT="@$ACTOR $(date -u +'%b %-d')"
fi
uv run scripts/edit_branches.py add "$FILE" "$BRANCH" --comment "$COMMENT"
git diff -- "$FILE"
- name: Commit and push
id: commit
run: |
if git diff --quiet -- "$FILE"; then
echo "No changes to commit"
exit 0
fi
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add "$FILE"
git commit -m "Add branch \`$BRANCH\` to $FILE"
git push
echo "changed=true" >> "$GITHUB_OUTPUT"
- name: Trigger commcare-hq rebuild
if: steps.commit.outputs.changed == 'true' && inputs.file == 'commcare-hq-staging.yml'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run trigger-commcare-hq-rebuild.yml --ref main