Skip to content

Commit d3585c0

Browse files
committed
user -ull_request_target
1 parent 24862bd commit d3585c0

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

.github/workflows/1-create-a-pr.yml

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
name: Step 1
22

33
on:
4-
pull_request:
5-
branches: [main] # Trigger only for PRs targeting the 'main' branch
6-
types: [opened] # Only when the PR is opened (created)
4+
pull_request_target:
5+
branches: [main]
6+
types: [opened]
7+
workflow_dispatch: {}
78

89
permissions:
910
contents: write
1011
actions: write
1112
issues: write
13+
pull-requests: write # Required for commenting or updating PR
1214

1315
env:
1416
STEP_2_FILE: ".github/steps/2-resolve-a-merge-conflict.md"
@@ -26,8 +28,10 @@ jobs:
2628
ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
2729

2830
steps:
29-
- name: Checkout
31+
- name: Checkout the base branch (main)
3032
uses: actions/checkout@v4
33+
with:
34+
ref: main # Required because pull_request_target runs in the base branch context
3135

3236
- name: Get response templates
3337
uses: actions/checkout@v4
@@ -56,19 +60,3 @@ jobs:
5660
gh workflow enable "Step 2"
5761
env:
5862
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59-
60-
# Debug steps (optional) ...
61-
- name: Debug - print event payload
62-
run: |
63-
echo "EVENT PAYLOAD:"
64-
cat $GITHUB_EVENT_PATH
65-
66-
- name: Debug - list files
67-
run: |
68-
echo "Current directory: $(pwd)"
69-
ls -al
70-
echo "Contents of .github/steps:"
71-
ls -al .github/steps || echo ".github/steps does not exist"
72-
73-
- name: Debug - print environment variables
74-
run: env

0 commit comments

Comments
 (0)