Skip to content

Refresh guide: google-calendar #278

Refresh guide: google-calendar

Refresh guide: google-calendar #278

Workflow file for this run

name: Guide draft
on:
issues:
types: [labeled]
jobs:
draft:
if: github.event.label.name == 'guide:draft'
runs-on: ubuntu-latest
timeout-minutes: 180
concurrency:
group: guide-draft-issue-${{ github.event.issue.number }}
cancel-in-progress: false
permissions:
contents: write
issues: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
token: ${{ secrets.AGENT_PAT || secrets.GITHUB_TOKEN }}
- name: Configure runner temp
run: printf 'TMPDIR=%s\n' "$RUNNER_TEMP" >>"$GITHUB_ENV"
- name: Set up publisher
id: publisher_setup
env:
GH_TOKEN: ${{ secrets.AGENT_PAT || secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
printf '%s\n' 'Publisher setup failed.' >"$RUNNER_TEMP/failure-reason.txt"
mkdir -p "$RUNNER_TEMP/guide-factory-publisher/factory/scripts"
cp factory/scripts/publish.sh factory/scripts/lib.sh \
"$RUNNER_TEMP/guide-factory-publisher/factory/scripts/"
PUBLISHER_PATH="$RUNNER_TEMP/guide-factory-publisher/factory/scripts/publish.sh"
printf 'PUBLISHER_PATH=%s\n' "$PUBLISHER_PATH" >>"$GITHUB_ENV"
bash "$PUBLISHER_PATH" ensure-labels
- name: Preflight existing factory work
id: preflight
env:
GH_TOKEN: ${{ secrets.AGENT_PAT || secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
printf '%s\n' 'Preflight failed.' >"$RUNNER_TEMP/failure-reason.txt"
bash factory/scripts/preflight.sh
- name: Refuse non-factory pull request
id: refusal
if: success() && steps.preflight.outputs.refused == 'true'
env:
GH_TOKEN: ${{ secrets.AGENT_PAT || secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
printf '%s\n' 'Refusal reporting failed.' >"$RUNNER_TEMP/failure-reason.txt"
bash "$PUBLISHER_PATH" refuse '${{ steps.preflight.outputs.refused_pr_url }}'
- name: Checkout resume branch and sync main
id: resume_sync
if: success() && steps.refusal.outcome != 'success' && steps.preflight.outputs.resume == 'true'
env:
RESUME_BRANCH: ${{ steps.preflight.outputs.resume_branch }}
run: |
printf '%s\n' 'Resume branch synchronization failed.' >"$RUNNER_TEMP/failure-reason.txt"
git config --local user.name github-actions[bot]
git config --local user.email 41898282+github-actions[bot]@users.noreply.github.com
git fetch origin main "$RESUME_BRANCH"
git checkout -B "$RESUME_BRANCH" "origin/$RESUME_BRANCH"
git merge --no-edit origin/main
- name: Transition labels
id: transition
if: success() && steps.refusal.outcome != 'success'
env:
GH_TOKEN: ${{ secrets.AGENT_PAT || secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
printf '%s\n' 'Label transition failed.' >"$RUNNER_TEMP/failure-reason.txt"
bash "$PUBLISHER_PATH" transition
- name: Prepare issue input
id: prepare_input
if: success() && steps.refusal.outcome != 'success'
env:
GH_TOKEN: ${{ secrets.AGENT_PAT || secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
printf '%s\n' 'Issue input preparation failed.' >"$RUNNER_TEMP/failure-reason.txt"
bash factory/scripts/prepare-input.sh '${{ github.event.issue.number }}' "$RUNNER_TEMP/issue.json"
- name: Prepare catalog snapshot
id: prepare_catalog
if: success() && steps.refusal.outcome != 'success'
env:
PULSE_REGISTRY_KEY: ${{ secrets.PULSE_REGISTRY_KEY }}
PULSE_REGISTRY_TENANT: ${{ secrets.PULSE_REGISTRY_TENANT }}
PULSE_REGISTRY_URL: ${{ secrets.PULSE_REGISTRY_URL }}
run: |
printf '%s\n' 'Catalog snapshot preparation failed.' >"$RUNNER_TEMP/failure-reason.txt"
bash factory/scripts/prepare-catalog.sh "$RUNNER_TEMP/catalog.json"
- name: Run Kit
id: kit
if: success() && steps.refusal.outcome != 'success'
env:
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
run: |
printf '%s\n' 'Kit execution failed.' >"$RUNNER_TEMP/failure-reason.txt"
bash factory/scripts/run-kit.sh \
"$RUNNER_TEMP/issue.json" \
"$RUNNER_TEMP/catalog.json" \
"$RUNNER_TEMP/export"
cp "$RUNNER_TEMP/export/run-report.json" "$RUNNER_TEMP/run-report.json"
- name: Upload safe factory diagnostics
if: failure() && steps.kit.outcome == 'failure'
uses: actions/upload-artifact@v4
with:
name: guide-factory-diagnostics-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/export/factory-diagnostics.json
retention-days: 7
if-no-files-found: ignore
- name: Validate export
id: validate
if: success() && steps.refusal.outcome != 'success'
run: |
printf '%s\n' 'Factory export validation failed.' >"$RUNNER_TEMP/failure-reason.txt"
bash factory/scripts/validate.sh "$RUNNER_TEMP/export" "$GITHUB_WORKSPACE"
- name: Publish guide
id: publish
if: success() && steps.refusal.outcome != 'success'
env:
GH_TOKEN: ${{ secrets.AGENT_PAT || secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
RESUME: ${{ steps.preflight.outputs.resume }}
RESUME_BRANCH: ${{ steps.preflight.outputs.resume_branch }}
RESUME_PR_NUMBER: ${{ steps.preflight.outputs.resume_pr_number }}
run: |
printf '%s\n' 'Guide publication failed.' >"$RUNNER_TEMP/failure-reason.txt"
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
bash "$PUBLISHER_PATH" publish "$RUNNER_TEMP/run-report.json"
- name: Report failure
id: failure_report
if: failure() && steps.publisher_setup.outcome == 'success' && steps.refusal.outcome != 'success'
env:
GH_TOKEN: ${{ secrets.AGENT_PAT || secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: bash "$PUBLISHER_PATH" fail "$RUNNER_TEMP/failure-reason.txt"
- name: Cleanup labels
id: cleanup
if: always() && steps.publisher_setup.outcome == 'success'
env:
GH_TOKEN: ${{ secrets.AGENT_PAT || secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: bash "$PUBLISHER_PATH" cleanup
- name: Bootstrap failure fallback
id: bootstrap_failure
if: always() && steps.publisher_setup.outcome != 'success'
env:
GH_TOKEN: ${{ secrets.AGENT_PAT || secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
status=0
gh label view guide:blocked --repo "$GH_REPO" >/dev/null 2>&1 ||
gh label create guide:blocked --repo "$GH_REPO" --color D73A4A \
--description 'Guide draft factory blocked' >/dev/null || status=$?
gh issue edit "$ISSUE_NUMBER" --repo "$GH_REPO" \
--remove-label guide:draft >/dev/null || status=$?
gh issue edit "$ISSUE_NUMBER" --repo "$GH_REPO" \
--remove-label guide:in-progress >/dev/null || status=$?
gh issue edit "$ISSUE_NUMBER" --repo "$GH_REPO" \
--add-label guide:blocked >/dev/null || status=$?
labels="$(gh issue view "$ISSUE_NUMBER" --repo "$GH_REPO" \
--json labels --jq '.labels[].name')" || status=$?
if grep -Fqx guide:draft <<<"$labels" ||
grep -Fqx guide:in-progress <<<"$labels" ||
! grep -Fqx guide:blocked <<<"$labels"; then
status=1
fi
printf '%s\n' \
'## Guide factory failed during publisher setup' '' \
"**Workflow run:** $RUN_URL" \
>"$RUNNER_TEMP/bootstrap-comment.md"
gh issue comment "$ISSUE_NUMBER" --repo "$GH_REPO" \
--body-file "$RUNNER_TEMP/bootstrap-comment.md" || status=$?
exit "$status"