From 6c7a413c88d4c7ff2283f0e76206e720de4ad875 Mon Sep 17 00:00:00 2001 From: MatteoGabriele Date: Thu, 26 Mar 2026 10:04:13 +0100 Subject: [PATCH 1/3] Revert "chore: update workflow permissions" This reverts commit 9f6e615802f456dc5fd4035583594097e59935c3. --- .github/workflows/auto-pr-verified-automations.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-pr-verified-automations.yml b/.github/workflows/auto-pr-verified-automations.yml index 2d9e4a6..122164a 100644 --- a/.github/workflows/auto-pr-verified-automations.yml +++ b/.github/workflows/auto-pr-verified-automations.yml @@ -161,7 +161,7 @@ jobs: - name: Find or create pull request id: pr env: - GH_TOKEN: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | BRANCH_NAME="${{ steps.check_branch.outputs.branch_name }}" USERNAME="${{ steps.parse_issue.outputs.username }}" @@ -202,7 +202,7 @@ jobs: - name: Comment on issue with PR link env: - GH_TOKEN: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | ISSUE_NUMBER="${{ github.event.issue.number }}" PR_NUMBER="${{ steps.pr.outputs.pr_number }}" From ee9cc6388d279d6a630bc1544758230aa34f01ba Mon Sep 17 00:00:00 2001 From: MatteoGabriele Date: Thu, 26 Mar 2026 10:04:21 +0100 Subject: [PATCH 2/3] Revert "chore: adjust template" This reverts commit 3f007fe8dc5cf733139f367ac89087b61ffb1326. --- .../ISSUE_TEMPLATE/report-automated-account.md | 16 ++++------------ .../workflows/auto-pr-verified-automations.yml | 14 ++++++++++---- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/report-automated-account.md b/.github/ISSUE_TEMPLATE/report-automated-account.md index f3598d5..8e162ac 100644 --- a/.github/ISSUE_TEMPLATE/report-automated-account.md +++ b/.github/ISSUE_TEMPLATE/report-automated-account.md @@ -5,18 +5,10 @@ title: "Community discussion: " labels: automated-account --- -## GitHub Username +**GitHub username:** - +**What are your thoughts about this account:** -## Reason +**Supporting evidence (links, screenshots):** - - -## Evidence - - - -## Additional Context (Optional) - - +**Any additional context:** diff --git a/.github/workflows/auto-pr-verified-automations.yml b/.github/workflows/auto-pr-verified-automations.yml index 122164a..8a7b9e2 100644 --- a/.github/workflows/auto-pr-verified-automations.yml +++ b/.github/workflows/auto-pr-verified-automations.yml @@ -24,11 +24,17 @@ jobs: ISSUE_BODY="${{ github.event.issue.body }}" ISSUE_NUMBER="${{ github.event.issue.number }}" - # Extract GitHub username (content between "## GitHub Username" and next section) - USERNAME=$(echo "$ISSUE_BODY" | sed -n '/^## GitHub Username/,/^##/p' | sed '1d;$d' | xargs) + # Extract GitHub username + USERNAME=$(echo "$ISSUE_BODY" | grep -A1 "^**GitHub username:**" | tail -1 | xargs) - # Extract reason (content between "## Reason" and next section) - REASON=$(echo "$ISSUE_BODY" | sed -n '/^## Reason/,/^##/p' | sed '1d;$d' | xargs) + # Extract reason (handle multi-line) + REASON=$(echo "$ISSUE_BODY" | sed -n '/^**What are your thoughts about this account:/,/^**/p' | sed '1d;$d' | xargs) + + # Create the issue URL + ISSUE_URL="https://github.com/${{ github.repository }}/issues/$ISSUE_NUMBER" + + # Create today's date in YYYY-MM-DD format + CREATED_AT=$(date -u +%Y-%m-%d) # Validate that we have required fields if [ -z "$USERNAME" ] || [ -z "$REASON" ]; then From a0a8bd3c1187819db7083c2b1048e05d705f2ade Mon Sep 17 00:00:00 2001 From: MatteoGabriele Date: Thu, 26 Mar 2026 10:04:25 +0100 Subject: [PATCH 3/3] Revert "chore: add automated issue to pr workflow" This reverts commit 4934a41792b9cee6da8f06c8f2d0c5674ab67f9d. --- .../auto-pr-verified-automations.yml | 252 ------------------ 1 file changed, 252 deletions(-) delete mode 100644 .github/workflows/auto-pr-verified-automations.yml diff --git a/.github/workflows/auto-pr-verified-automations.yml b/.github/workflows/auto-pr-verified-automations.yml deleted file mode 100644 index 8a7b9e2..0000000 --- a/.github/workflows/auto-pr-verified-automations.yml +++ /dev/null @@ -1,252 +0,0 @@ -name: Auto-PR for Verified Automations - -on: - issues: - types: [opened, edited] - -permissions: - contents: write - pull-requests: write - issues: read - -jobs: - process-automated-account-report: - runs-on: ubuntu-latest - # Only run if the issue has the 'automated-account' label - if: contains(github.event.issue.labels.*.name, 'automated-account') - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Parse issue body - id: parse_issue - run: | - ISSUE_BODY="${{ github.event.issue.body }}" - ISSUE_NUMBER="${{ github.event.issue.number }}" - - # Extract GitHub username - USERNAME=$(echo "$ISSUE_BODY" | grep -A1 "^**GitHub username:**" | tail -1 | xargs) - - # Extract reason (handle multi-line) - REASON=$(echo "$ISSUE_BODY" | sed -n '/^**What are your thoughts about this account:/,/^**/p' | sed '1d;$d' | xargs) - - # Create the issue URL - ISSUE_URL="https://github.com/${{ github.repository }}/issues/$ISSUE_NUMBER" - - # Create today's date in YYYY-MM-DD format - CREATED_AT=$(date -u +%Y-%m-%d) - - # Validate that we have required fields - if [ -z "$USERNAME" ] || [ -z "$REASON" ]; then - echo "ERROR: Missing required fields in issue body" - echo " GitHub username: '$USERNAME'" - echo " Reason: '$REASON'" - exit 1 - fi - - # Export variables for next steps - echo "username=$USERNAME" >> $GITHUB_OUTPUT - echo "reason=$REASON" >> $GITHUB_OUTPUT - echo "issue_url=$ISSUE_URL" >> $GITHUB_OUTPUT - echo "created_at=$CREATED_AT" >> $GITHUB_OUTPUT - - echo "Successfully parsed issue:" - echo " Username: $USERNAME" - echo " Reason: ${REASON:0:60}..." - echo " URL: $ISSUE_URL" - echo " Date: $CREATED_AT" - - - name: Configure git - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - - - name: Fetch all branches - run: git fetch origin - - - name: Check for existing PR branch - id: check_branch - run: | - BRANCH_NAME="verified-automation-${{ steps.parse_issue.outputs.username }}" - - if git rev-parse --verify "origin/$BRANCH_NAME" > /dev/null 2>&1; then - echo "exists=true" >> $GITHUB_OUTPUT - echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT - echo "Branch already exists: $BRANCH_NAME" - else - echo "exists=false" >> $GITHUB_OUTPUT - echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT - echo "Will create new branch: $BRANCH_NAME" - fi - - - name: Checkout or create branch - run: | - BRANCH_NAME="${{ steps.check_branch.outputs.branch_name }}" - - if [ "${{ steps.check_branch.outputs.exists }}" = "true" ]; then - git checkout "$BRANCH_NAME" - else - git checkout -b "$BRANCH_NAME" - fi - - - name: Update verified-automations-list.json - id: update_json - run: | - JSON_FILE="data/verified-automations-list.json" - USERNAME="${{ steps.parse_issue.outputs.username }}" - REASON="${{ steps.parse_issue.outputs.reason }}" - ISSUE_URL="${{ steps.parse_issue.outputs.issue_url }}" - CREATED_AT="${{ steps.parse_issue.outputs.created_at }}" - - # Read existing JSON - if [ -f "$JSON_FILE" ]; then - EXISTING=$(cat "$JSON_FILE") - else - EXISTING="[]" - fi - - # Check if username already exists and get its index - EXISTING_INDEX=$(echo "$EXISTING" | jq ".[] | select(.username==\"$USERNAME\") | .username" 2>/dev/null | head -1) - - if [ ! -z "$EXISTING_INDEX" ]; then - echo "Username '$USERNAME' already exists, updating entry..." - # Update existing entry - UPDATED=$(echo "$EXISTING" | jq --arg username "$USERNAME" --arg reason "$REASON" --arg issueUrl "$ISSUE_URL" --arg createdAt "$CREATED_AT" 'map(if .username == $username then { username: .username, reason: $reason, issueUrl: $issueUrl, createdAt: .createdAt } else . end)') - else - echo "Adding new entry for '$USERNAME'..." - # Create new entry and append - UPDATED=$(echo "$EXISTING" | jq --arg username "$USERNAME" --arg reason "$REASON" --arg issueUrl "$ISSUE_URL" --arg createdAt "$CREATED_AT" '. += [{ username: $username, reason: $reason, issueUrl: $issueUrl, createdAt: $createdAt }]') - fi - - # Sort by createdAt (newest first) and format with 2-space indent - SORTED=$(echo "$UPDATED" | jq -S 'sort_by(.createdAt) | reverse') - - # Validate JSON - if ! echo "$SORTED" | jq empty 2>/dev/null; then - echo "ERROR: Invalid JSON generated!" - exit 1 - fi - - # Write formatted JSON to file - echo "$SORTED" | jq '.' > "$JSON_FILE" - - echo "JSON updated successfully" - cat "$JSON_FILE" - - - name: Commit changes - id: commit - run: | - JSON_FILE="data/verified-automations-list.json" - USERNAME="${{ steps.parse_issue.outputs.username }}" - - git add "$JSON_FILE" - - if git diff --cached --quiet; then - echo "changed=false" >> $GITHUB_OUTPUT - echo "No changes to commit" - else - git commit -m "Add/Update verified automation for $USERNAME - - Issue: ${{ steps.parse_issue.outputs.issue_url }}" - echo "changed=true" >> $GITHUB_OUTPUT - echo "Changes committed" - fi - - - name: Push branch - run: | - BRANCH_NAME="${{ steps.check_branch.outputs.branch_name }}" - - if [ "${{ steps.check_branch.outputs.exists }}" = "true" ]; then - git push origin "$BRANCH_NAME" --force-with-lease - echo "Branch updated on remote" - else - git push -u origin "$BRANCH_NAME" - echo "New branch pushed to remote" - fi - - - name: Find or create pull request - id: pr - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - BRANCH_NAME="${{ steps.check_branch.outputs.branch_name }}" - USERNAME="${{ steps.parse_issue.outputs.username }}" - ISSUE_NUMBER="${{ github.event.issue.number }}" - ISSUE_URL="${{ steps.parse_issue.outputs.issue_url }}" - - # Search for existing PR - PR_NUMBER=$(gh pr list --head "$BRANCH_NAME" --state open --json number -q '.[0].number' 2>/dev/null) - - if [ ! -z "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then - PR_URL="https://github.com/${{ github.repository }}/pull/$PR_NUMBER" - echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT - echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT - echo "pr_created=false" >> $GITHUB_OUTPUT - echo "Found existing PR #$PR_NUMBER" - else - # Create new PR - PR_TITLE="Add $USERNAME to verified automations" - PR_BODY="This PR adds \`$USERNAME\` to the list of verified automated accounts. - - **Reference Issue:** $ISSUE_URL - **Issue #:** $ISSUE_NUMBER - - **Changes Made:** - - Added entry to \`data/verified-automations-list.json\` - - Entry automatically syncs with issue updates - - *This PR was automatically created by the Auto-PR workflow.*" - - PR_URL=$(gh pr create --title "$PR_TITLE" --body "$PR_BODY" --head "$BRANCH_NAME" --base main) - PR_NUMBER=$(echo "$PR_URL" | grep -oP 'pull/\K[0-9]+' | head -1) - - echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT - echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT - echo "pr_created=true" >> $GITHUB_OUTPUT - echo "Created new PR #$PR_NUMBER" - fi - - - name: Comment on issue with PR link - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - ISSUE_NUMBER="${{ github.event.issue.number }}" - PR_NUMBER="${{ steps.pr.outputs.pr_number }}" - PR_URL="${{ steps.pr.outputs.pr_url }}" - IS_NEW="${{ steps.pr.outputs.pr_created }}" - - if [ -z "$PR_URL" ]; then - echo "Skipping comment: PR URL not available" - exit 0 - fi - - if [ "$IS_NEW" = "true" ]; then - COMMENT="Automated PR created! - - I've created a pull request to add this verified automation entry. - - **PR Link:** $PR_URL - - The entry in \`data/verified-automations-list.json\` will automatically sync whenever you update this issue." - else - COMMENT="PR Updated! - - I've updated the pull request with your changes. - - **PR Link:** $PR_URL - - The entry in \`data/verified-automations-list.json\` has been synced with your latest update." - fi - - gh issue comment "$ISSUE_NUMBER" --body "$COMMENT" - echo "Comment posted on issue #$ISSUE_NUMBER" - - - name: Summary - if: always() - run: | - echo "Workflow Summary:" - echo "==================" - echo "Username: ${{ steps.parse_issue.outputs.username }}" - echo "Issue: ${{ steps.parse_issue.outputs.issue_url }}" - echo "Branch: ${{ steps.check_branch.outputs.branch_name }}" - echo "PR: ${{ steps.pr.outputs.pr_url }}"