Remove branch from staging config #13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Remove branch from 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 remove' | |
| required: true | |
| type: string | |
| reason: | |
| description: 'Reason for removal' | |
| required: false | |
| type: choice | |
| default: unspecified | |
| options: | |
| - unspecified | |
| - merge | |
| - conflict | |
| jobs: | |
| remove-branch: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| actions: write | |
| env: | |
| FILE: ${{ inputs.file }} | |
| BRANCH: ${{ inputs.branch }} | |
| REASON: ${{ inputs.reason }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| - uses: astral-sh/setup-uv@v6 | |
| - name: Remove branch from config | |
| run: | | |
| uv run scripts/edit_branches.py remove "$FILE" "$BRANCH" | |
| 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" | |
| case "$REASON" in | |
| merge) MSG="Remove merged branch \`$BRANCH\` from $FILE" ;; | |
| conflict) MSG="Remove conflicting branch \`$BRANCH\` from $FILE" ;; | |
| *) MSG="Remove branch \`$BRANCH\` from $FILE" ;; | |
| esac | |
| git commit -m "$MSG" | |
| 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 |