Setup Test Resources #5
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: Setup Test Resources | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| create_project: | |
| description: 'Create GitHub Project board' | |
| required: false | |
| type: boolean | |
| default: true | |
| permissions: | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Git | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Create test resources | |
| env: | |
| # Use the default GITHUB_TOKEN for issues/PRs. | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Projects v2 operations require a separate token with Projects write access. | |
| PROJECTS_GITHUB_TOKEN: ${{ secrets.PROJECTS_GITHUB_TOKEN }} | |
| run: | | |
| set -e | |
| REPO="${{ github.repository }}" | |
| TEMPLATE_FILE="notes/2026/2026-01-13-transcript.template.md" | |
| TRANSCRIPT_FILE="notes/2026/2026-01-13-transcript.md" | |
| echo "Creating test GitHub resources in $REPO..." | |
| echo "" | |
| # Create issue for regression | |
| echo "Creating issue about regression..." | |
| ISSUE_URL=$(gh issue create \ | |
| --repo "$REPO" \ | |
| --title "Regression discussion" \ | |
| --body "This issue was created for testing the transcript follow-up workflow. It represents a regression that was discussed in the 2026-01-13 meeting." \ | |
| --label "bug") | |
| ISSUE_REGRESSION=$(echo "$ISSUE_URL" | grep -oE '[0-9]+$') | |
| echo " Created issue #$ISSUE_REGRESSION" | |
| # Create issue for context | |
| echo "Creating context issue..." | |
| ISSUE_URL=$(gh issue create \ | |
| --repo "$REPO" \ | |
| --title "Related context issue" \ | |
| --body "This issue provides additional context for the transcript follow-up workflow testing.") | |
| ISSUE_CONTEXT=$(echo "$ISSUE_URL" | grep -oE '[0-9]+$') | |
| echo " Created issue #$ISSUE_CONTEXT" | |
| # Create issue for bare reference | |
| echo "Creating bare reference issue..." | |
| ISSUE_URL=$(gh issue create \ | |
| --repo "$REPO" \ | |
| --title "Bare reference test" \ | |
| --body "This issue tests handling of bare issue references in transcripts.") | |
| ISSUE_BARE=$(echo "$ISSUE_URL" | grep -oE '[0-9]+$') | |
| echo " Created issue #$ISSUE_BARE" | |
| # Create a test branch and PR | |
| echo "Creating test PR..." | |
| BRANCH_NAME="test-pr-$(date +%s)" | |
| git checkout -b "$BRANCH_NAME" | |
| echo "# Test PR" > test-file.md | |
| git add test-file.md | |
| git commit -m "Test commit for PR workflow" | |
| git push origin "$BRANCH_NAME" | |
| PR_URL=$(gh pr create \ | |
| --repo "$REPO" \ | |
| --title "Test PR for transcript workflow" \ | |
| --body "This PR needs a status update comment as decided in the 2026-01-13 meeting." \ | |
| --base main \ | |
| --head "$BRANCH_NAME") | |
| PR_TEST=$(echo "$PR_URL" | grep -oE '[0-9]+$') | |
| echo " Created PR #$PR_TEST" | |
| git checkout main | |
| # Create GitHub Project if requested | |
| if [ "${{ inputs.create_project }}" = "true" ]; then | |
| echo "" | |
| echo "Creating GitHub Project..." | |
| if [ -z "${PROJECTS_GITHUB_TOKEN:-}" ]; then | |
| echo "::error::Projects linking requires a token with Projects write access. Set the PROJECTS_GITHUB_TOKEN secret (classic PAT with 'project' scope, or a fine-grained token with Projects: Read and write + access to this repo)." | |
| exit 1 | |
| fi | |
| # Extract owner from repo | |
| OWNER=$(echo "$REPO" | cut -d'/' -f1) | |
| # Create project and capture output | |
| PROJECT_OUTPUT=$(GH_TOKEN="$PROJECTS_GITHUB_TOKEN" gh project create \ | |
| --owner "$OWNER" \ | |
| --title "Transcript Follow-up Test" \ | |
| --format json 2>&1 || echo "{}") | |
| # Extract project number from JSON output | |
| if echo "$PROJECT_OUTPUT" | grep -q '"number"'; then | |
| PROJECT_NUMBER=$(echo "$PROJECT_OUTPUT" | grep -oE '"number":\s*[0-9]+' | grep -oE '[0-9]+') | |
| echo " Created project #$PROJECT_NUMBER" | |
| # Link project to repository | |
| echo " Linking project to repository..." | |
| if LINK_OUTPUT=$(gh project link "$PROJECT_NUMBER" --owner "$OWNER" --repo "$REPO" 2>&1); then | |
| echo " ✓ Project linked successfully" | |
| else | |
| echo " Warning: Could not link project to repository" | |
| echo " Linking requires a token with 'project' scope (set PROJECTS_GITHUB_TOKEN secret)" | |
| echo " Error details: $LINK_OUTPUT" | |
| echo " To link manually: https://github.com/orgs/$OWNER/projects/$PROJECT_NUMBER" | |
| fi | |
| else | |
| echo " Warning: Could not extract project number, using placeholder" | |
| echo " Output was: $PROJECT_OUTPUT" | |
| PROJECT_NUMBER="6" | |
| fi | |
| else | |
| echo "" | |
| echo "Skipping project creation" | |
| PROJECT_NUMBER="6" | |
| fi | |
| echo "" | |
| echo "Updating transcript with actual numbers..." | |
| # Update transcript from template | |
| sed -e "s/{{ISSUE_REGRESSION}}/$ISSUE_REGRESSION/g" \ | |
| -e "s/{{ISSUE_CONTEXT}}/$ISSUE_CONTEXT/g" \ | |
| -e "s/{{ISSUE_BARE}}/$ISSUE_BARE/g" \ | |
| -e "s/{{PR_TEST}}/$PR_TEST/g" \ | |
| -e "s/{{PROJECT_NUMBER}}/$PROJECT_NUMBER/g" \ | |
| "$TEMPLATE_FILE" > "$TRANSCRIPT_FILE" | |
| # Commit the updated transcript | |
| git add "$TRANSCRIPT_FILE" | |
| if ! git diff --staged --quiet; then | |
| git commit -m "Update transcript with test resource numbers [skip ci]" | |
| git push origin main | |
| fi | |
| echo "" | |
| echo "✅ Resources created and transcript updated!" | |
| echo "" | |
| echo "Created resources:" | |
| echo " Issue (Regression): #$ISSUE_REGRESSION" | |
| echo " Issue (Context): #$ISSUE_CONTEXT" | |
| echo " Issue (Bare ref): #$ISSUE_BARE" | |
| echo " PR (Test): #$PR_TEST" | |
| if [ "${{ inputs.create_project }}" = "true" ]; then | |
| echo " Project: #$PROJECT_NUMBER" | |
| fi | |
| echo "" | |
| echo "Transcript file updated: $TRANSCRIPT_FILE" |