spirit-tracker/.github/workflows/stviz_create_pr_from_issue.yml
Brennan Wilkes (Text Groove) 25433757be fix: Git auth
2026-01-22 10:54:47 -08:00

61 lines
1.9 KiB
YAML

name: STVIZ - Create PR from Issue
on:
issues:
types: [opened]
permissions:
contents: write
pull-requests: write
issues: write
jobs:
apply:
if: contains(github.event.issue.title, '[stviz]') || contains(github.event.issue.body, 'stviz-sku-edits:BEGIN')
runs-on: ubuntu-latest
steps:
- name: Checkout data branch
uses: actions/checkout@v4
with:
ref: data
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Configure git author
shell: bash
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Apply edits, push branch, open PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_BODY: ${{ github.event.issue.body }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
node tools/stviz_apply_issue_edits.js
- name: Close issue
if: always()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
REPO: ${{ github.repository }}
shell: bash
run: |
set -euo pipefail
# Close only if a PR exists for this issue number; otherwise leave it open.
if gh -R "$REPO" pr list --state open --search "issue #$ISSUE_NUMBER" --json number --jq 'length' | grep -qv '^0$'; then
gh -R "$REPO" issue close "$ISSUE_NUMBER" -c "Processed by STVIZ automation and a PR was opened."
else
echo "No PR detected for issue #$ISSUE_NUMBER; leaving issue open."
fi