Skip to content

Commit b5259da

Browse files
authored
Merge branch 'main' into fix-test
2 parents 0db2e57 + 761a4a8 commit b5259da

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Test PR Automated Comments
2+
3+
on:
4+
# Manual trigger for testing
5+
workflow_dispatch:
6+
inputs:
7+
test_event_type:
8+
description: 'Event type to simulate for testing'
9+
required: true
10+
type: choice
11+
options:
12+
- opened
13+
- ready_for_review
14+
- merged
15+
16+
jobs:
17+
# When manually triggered, we need to simulate the PR event context
18+
prepare-test-context:
19+
name: Prepare Test Context
20+
runs-on: ubuntu-latest
21+
outputs:
22+
is_external: 'true'
23+
is_first_pr: ${{ steps.set-context.outputs.is_first_pr }}
24+
event_type: ${{ steps.set-context.outputs.event_type }}
25+
steps:
26+
- name: Set test context variables
27+
id: set-context
28+
run: |
29+
EVENT_TYPE="${{ github.event.inputs.test_event_type }}"
30+
echo "event_type=$EVENT_TYPE" >> $GITHUB_OUTPUT
31+
32+
# For the opened event, we need to simulate first PR status
33+
if [[ "$EVENT_TYPE" == "opened" ]]; then
34+
echo "is_first_pr=true" >> $GITHUB_OUTPUT
35+
else
36+
echo "is_first_pr=false" >> $GITHUB_OUTPUT
37+
fi
38+
39+
# Test workflow for manual triggering - using the actual reusable workflow
40+
first-pr-comment-test:
41+
name: First PR Comment (Test)
42+
needs: prepare-test-context
43+
if: needs.prepare-test-context.outputs.event_type == 'opened'
44+
uses: ./.github/workflows/pr-auto-comments.yml
45+
with:
46+
org_name: "RequestNetwork"
47+
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)"
48+
ready_for_review_comment: ""
49+
merged_pr_comment: ""
50+
secrets:
51+
token: ${{ secrets.GITHUB_TOKEN }}
52+
53+
ready-for-review-comment-test:
54+
name: Ready for Review Comment (Test)
55+
needs: prepare-test-context
56+
if: needs.prepare-test-context.outputs.event_type == 'ready_for_review'
57+
uses: ./.github/workflows/pr-auto-comments.yml
58+
with:
59+
org_name: "RequestNetwork"
60+
first_pr_comment: ""
61+
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)"
62+
merged_pr_comment: ""
63+
secrets:
64+
token: ${{ secrets.GITHUB_TOKEN }}
65+
66+
merged-pr-comment-test:
67+
name: Merged PR Comment (Test)
68+
needs: prepare-test-context
69+
if: needs.prepare-test-context.outputs.event_type == 'merged'
70+
uses: ./.github/workflows/pr-auto-comments.yml
71+
with:
72+
org_name: "RequestNetwork"
73+
first_pr_comment: ""
74+
ready_for_review_comment: ""
75+
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)"
76+
secrets:
77+
token: ${{ secrets.GITHUB_TOKEN }}
78+
79+
# Add completion notification
80+
notify-test-completion:
81+
name: Notify Test Completion
82+
needs: [prepare-test-context]
83+
runs-on: ubuntu-latest
84+
steps:
85+
- name: Create notification issue comment
86+
uses: actions/github-script@v6
87+
with:
88+
github-token: ${{ secrets.GITHUB_TOKEN }}
89+
script: |
90+
const eventType = '${{ needs.prepare-test-context.outputs.event_type }}';
91+
const repoName = context.repo.repo;
92+
const orgName = context.repo.owner;
93+
94+
console.log(`Running test for ${eventType} event in ${orgName}/${repoName}`);
95+
96+
try {
97+
const issue_number = 1; // Use issue #1 as fallback
98+
99+
await github.rest.issues.createComment({
100+
owner: context.repo.owner,
101+
repo: context.repo.repo,
102+
issue_number: issue_number,
103+
body: `## Test for "${eventType}" PR Event Initiated
104+
105+
A test of the \`${eventType}\` PR event comment has been initiated.
106+
107+
**Note:** Since this is a manual test, this will use hard-coded test variables:
108+
- Repository: ${repoName}
109+
- Organization: ${orgName}
110+
- Testing as an external contributor
111+
112+
Check the [Actions tab](https://github.com/${orgName}/${repoName}/actions/workflows/pr-auto-comments-test.yml) to see the workflow execution.
113+
114+
*This is a notification from the manual test trigger.*`
115+
});
116+
console.log('Created notification comment on issue #1');
117+
} catch (error) {
118+
console.log('Error creating comment:', error);
119+
console.log('Continuing without creating a comment');
120+
}

0 commit comments

Comments
 (0)