8
8
create-test-pr :
9
9
runs-on : ubuntu-latest
10
10
steps :
11
+ - name : Generate GitHub App Token
12
+ id : generate_token
13
+ uses : actions/create-github-app-token@v1
14
+ with :
15
+ app-id : ${{ vars.APP_ID }}
16
+ private-key : ${{ secrets.APP_PRIVATE_KEY }}
17
+ continue-on-error : true
18
+
11
19
- name : Checkout
12
20
uses : actions/checkout@v4
13
21
with :
14
- token : ${{ secrets.GITHUB_TOKEN }}
22
+ # Use app token if available, otherwise fallback to GITHUB_TOKEN
23
+ token : ${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}
15
24
ref : auto-approve-merge
16
25
17
26
- name : Create test branch and file
@@ -27,18 +36,21 @@ jobs:
27
36
echo "Test auto-merge at $(date)" > test-auto-merge.txt
28
37
echo "This file can be deleted after testing" >> test-auto-merge.txt
29
38
30
- # Configure git ( as github-actions bot)
39
+ # Configure git explicitly as github-actions bot
31
40
git config user.name "github-actions[bot]"
32
- git config user.email "github-actions[bot]@users.noreply.github.com"
41
+ git config user.email "41898282+ github-actions[bot]@users.noreply.github.com"
33
42
34
- # Commit and push
43
+ # Commit with explicit author
35
44
git add test-auto-merge.txt
36
- git commit -m "test: auto-merge functionality"
45
+ git commit -m "test: auto-merge functionality" \
46
+ --author="github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
47
+
48
+ # Push with the token that creates the PR
37
49
git push origin $BRANCH_NAME
38
50
39
51
- name : Create PR using GitHub API
40
52
run : |
41
- # Create PR using gh CLI
53
+ # The PR will be created by whatever token is used here
42
54
PR_URL=$(gh pr create \
43
55
--base auto-approve-merge \
44
56
--head $BRANCH_NAME \
49
61
- Can be closed if auto-merge fails")
50
62
51
63
echo "Created PR: $PR_URL"
64
+ echo "PR_URL=$PR_URL" >> $GITHUB_ENV
65
+
66
+ - name : Verify PR details
67
+ run : |
68
+ # Extract PR number from URL
69
+ PR_NUMBER=$(echo $PR_URL | grep -oE '[0-9]+$')
70
+
71
+ # Check the actual commit author
72
+ echo "Checking commit author on the PR..."
73
+ gh api repos/${{ github.repository }}/pulls/$PR_NUMBER/commits \
74
+ --jq '.[0].commit.author'
52
75
env :
53
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
76
+ GITHUB_TOKEN : ${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}
0 commit comments