From d1bc8f92b6768a7c0ac02d8a77ad375fbb243eb4 Mon Sep 17 00:00:00 2001 From: MantisClone Date: Thu, 20 Mar 2025 17:31:31 -0400 Subject: [PATCH 1/2] fix: test --- ...nts-test.yml => test-pr-auto-comments.yml} | 69 ++++++++----------- 1 file changed, 29 insertions(+), 40 deletions(-) rename .github/workflows/{pr-auto-comments-test.yml => test-pr-auto-comments.yml} (66%) diff --git a/.github/workflows/pr-auto-comments-test.yml b/.github/workflows/test-pr-auto-comments.yml similarity index 66% rename from .github/workflows/pr-auto-comments-test.yml rename to .github/workflows/test-pr-auto-comments.yml index e4ab9a9..ab52e58 100644 --- a/.github/workflows/pr-auto-comments-test.yml +++ b/.github/workflows/test-pr-auto-comments.yml @@ -1,10 +1,6 @@ -name: PR Automated Comments Test +name: Test PR Automated Comments on: - # Automatic triggers - pull_request_target: - types: [opened, ready_for_review, closed] - # Manual trigger for testing workflow_dispatch: inputs: @@ -21,7 +17,6 @@ jobs: # When manually triggered, we need to simulate the PR event context prepare-test-context: name: Prepare Test Context - if: github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest outputs: is_external: 'true' @@ -41,25 +36,12 @@ jobs: echo "is_first_pr=false" >> $GITHUB_OUTPUT fi - # Real workflow for actual PR events - pr-comments-real: - name: PR Comments (Real) - if: github.event_name == 'pull_request_target' - uses: ./.github/workflows/pr-auto-comments.yml@${{ github.ref_name }} - with: - org_name: "RequestNetwork" - # You can specify additional internal users here if needed - additional_internal_users: "" - # Use default messages - secrets: - token: ${{ secrets.GITHUB_TOKEN }} - # Test workflow for manual triggering - using the actual reusable workflow first-pr-comment-test: name: First PR Comment (Test) needs: prepare-test-context - if: github.event_name == 'workflow_dispatch' && needs.prepare-test-context.outputs.event_type == 'opened' - uses: ./.github/workflows/pr-auto-comments.yml@${{ github.ref_name }} + if: needs.prepare-test-context.outputs.event_type == 'opened' + uses: ./.github/workflows/pr-auto-comments.yml with: org_name: "RequestNetwork" first_pr_comment: "Hello @{{username}}, thank you for submitting your first pull request to the {{repository}} repository. We value your contribution and encourage you to review our contribution guidelines to ensure your submission meets our standards. Please note that every merged PR is automatically enrolled in our Best PR Initiative, offering a chance to win $500 each quarter. Our team is available via GitHub Discussions or Discord if you have any questions. Welcome aboard! (TEST)" @@ -71,8 +53,8 @@ jobs: ready-for-review-comment-test: name: Ready for Review Comment (Test) needs: prepare-test-context - if: github.event_name == 'workflow_dispatch' && needs.prepare-test-context.outputs.event_type == 'ready_for_review' - uses: ./.github/workflows/pr-auto-comments.yml@${{ github.ref_name }} + if: needs.prepare-test-context.outputs.event_type == 'ready_for_review' + uses: ./.github/workflows/pr-auto-comments.yml with: org_name: "RequestNetwork" first_pr_comment: "" @@ -84,8 +66,8 @@ jobs: merged-pr-comment-test: name: Merged PR Comment (Test) needs: prepare-test-context - if: github.event_name == 'workflow_dispatch' && needs.prepare-test-context.outputs.event_type == 'merged' - uses: ./.github/workflows/pr-auto-comments.yml@${{ github.ref_name }} + if: needs.prepare-test-context.outputs.event_type == 'merged' + uses: ./.github/workflows/pr-auto-comments.yml with: org_name: "RequestNetwork" first_pr_comment: "" @@ -98,7 +80,6 @@ jobs: notify-test-completion: name: Notify Test Completion needs: [prepare-test-context] - if: github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - name: Create notification issue comment @@ -110,22 +91,30 @@ jobs: const repoName = context.repo.repo; const orgName = context.repo.owner; - const issue_number = context.issue.number || 1; + console.log(`Running test for ${eventType} event in ${orgName}/${repoName}`); + + try { + const issue_number = 1; // Use issue #1 as fallback - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issue_number, - body: `## Test for "${eventType}" PR Event Initiated + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + body: `## Test for "${eventType}" PR Event Initiated - A test of the \`${eventType}\` PR event comment has been initiated. + A test of the \`${eventType}\` PR event comment has been initiated. - **Note:** Since this is a manual test, this will use hard-coded test variables: - - Repository: ${repoName} - - Organization: ${orgName} - - Testing as an external contributor + **Note:** Since this is a manual test, this will use hard-coded test variables: + - Repository: ${repoName} + - Organization: ${orgName} + - Testing as an external contributor - Check the [Actions tab](https://github.com/${orgName}/${repoName}/actions/workflows/repo-pr-comments.yml) to see the workflow execution. + Check the [Actions tab](https://github.com/${orgName}/${repoName}/actions/workflows/pr-auto-comments-test.yml) to see the workflow execution. - *This is a notification from the manual test trigger.*` - }); \ No newline at end of file + *This is a notification from the manual test trigger.*` + }); + console.log('Created notification comment on issue #1'); + } catch (error) { + console.log('Error creating comment:', error); + console.log('Continuing without creating a comment'); + } \ No newline at end of file From 0db2e578e64a651f367fc1e3708a6579245d3c53 Mon Sep 17 00:00:00 2001 From: MantisClone Date: Fri, 21 Mar 2025 16:02:09 -0400 Subject: [PATCH 2/2] fix: delete test-pr-auto-comments.yml --- .github/workflows/test-pr-auto-comments.yml | 120 -------------------- 1 file changed, 120 deletions(-) delete mode 100644 .github/workflows/test-pr-auto-comments.yml diff --git a/.github/workflows/test-pr-auto-comments.yml b/.github/workflows/test-pr-auto-comments.yml deleted file mode 100644 index ab52e58..0000000 --- a/.github/workflows/test-pr-auto-comments.yml +++ /dev/null @@ -1,120 +0,0 @@ -name: Test PR Automated Comments - -on: - # Manual trigger for testing - workflow_dispatch: - inputs: - test_event_type: - description: 'Event type to simulate for testing' - required: true - type: choice - options: - - opened - - ready_for_review - - merged - -jobs: - # When manually triggered, we need to simulate the PR event context - prepare-test-context: - name: Prepare Test Context - runs-on: ubuntu-latest - outputs: - is_external: 'true' - is_first_pr: ${{ steps.set-context.outputs.is_first_pr }} - event_type: ${{ steps.set-context.outputs.event_type }} - steps: - - name: Set test context variables - id: set-context - run: | - EVENT_TYPE="${{ github.event.inputs.test_event_type }}" - echo "event_type=$EVENT_TYPE" >> $GITHUB_OUTPUT - - # For the opened event, we need to simulate first PR status - if [[ "$EVENT_TYPE" == "opened" ]]; then - echo "is_first_pr=true" >> $GITHUB_OUTPUT - else - echo "is_first_pr=false" >> $GITHUB_OUTPUT - fi - - # Test workflow for manual triggering - using the actual reusable workflow - first-pr-comment-test: - name: First PR Comment (Test) - needs: prepare-test-context - if: needs.prepare-test-context.outputs.event_type == 'opened' - uses: ./.github/workflows/pr-auto-comments.yml - with: - org_name: "RequestNetwork" - first_pr_comment: "Hello @{{username}}, thank you for submitting your first pull request to the {{repository}} repository. We value your contribution and encourage you to review our contribution guidelines to ensure your submission meets our standards. Please note that every merged PR is automatically enrolled in our Best PR Initiative, offering a chance to win $500 each quarter. Our team is available via GitHub Discussions or Discord if you have any questions. Welcome aboard! (TEST)" - ready_for_review_comment: "" - merged_pr_comment: "" - secrets: - token: ${{ secrets.GITHUB_TOKEN }} - - ready-for-review-comment-test: - name: Ready for Review Comment (Test) - needs: prepare-test-context - if: needs.prepare-test-context.outputs.event_type == 'ready_for_review' - uses: ./.github/workflows/pr-auto-comments.yml - with: - org_name: "RequestNetwork" - first_pr_comment: "" - ready_for_review_comment: "Thank you for your submission! As you prepare for the review process, please ensure that your PR title, description, and any linked issues fully comply with our contribution guidelines. A clear explanation of your changes and their context will help expedite the review process. Every merged PR is automatically entered into our Best PR Initiative, offering a chance to win $500 every quarter. We appreciate your attention to detail and look forward to reviewing your contribution! (TEST)" - merged_pr_comment: "" - secrets: - token: ${{ secrets.GITHUB_TOKEN }} - - merged-pr-comment-test: - name: Merged PR Comment (Test) - needs: prepare-test-context - if: needs.prepare-test-context.outputs.event_type == 'merged' - uses: ./.github/workflows/pr-auto-comments.yml - with: - org_name: "RequestNetwork" - first_pr_comment: "" - ready_for_review_comment: "" - merged_pr_comment: "Congratulations, your pull request has been merged! Thank you for your valuable contribution to Request Network. As a reminder, every merged PR is automatically entered into our Best PR Initiative, offering a quarterly prize of $500. Your work significantly supports our project's growth, and we encourage you to continue engaging with our community. Additionally, if you want to build or add crypto payments and invoicing features, explore how our API can reduce deployment time from months to hours while offering advanced features. Book a call with our expert to learn more and fast-track your development. (TEST)" - secrets: - token: ${{ secrets.GITHUB_TOKEN }} - - # Add completion notification - notify-test-completion: - name: Notify Test Completion - needs: [prepare-test-context] - runs-on: ubuntu-latest - steps: - - name: Create notification issue comment - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const eventType = '${{ needs.prepare-test-context.outputs.event_type }}'; - const repoName = context.repo.repo; - const orgName = context.repo.owner; - - console.log(`Running test for ${eventType} event in ${orgName}/${repoName}`); - - try { - const issue_number = 1; // Use issue #1 as fallback - - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issue_number, - body: `## Test for "${eventType}" PR Event Initiated - - A test of the \`${eventType}\` PR event comment has been initiated. - - **Note:** Since this is a manual test, this will use hard-coded test variables: - - Repository: ${repoName} - - Organization: ${orgName} - - Testing as an external contributor - - Check the [Actions tab](https://github.com/${orgName}/${repoName}/actions/workflows/pr-auto-comments-test.yml) to see the workflow execution. - - *This is a notification from the manual test trigger.*` - }); - console.log('Created notification comment on issue #1'); - } catch (error) { - console.log('Error creating comment:', error); - console.log('Continuing without creating a comment'); - } \ No newline at end of file