Skip to content

Commit affea29

Browse files
committed
update test action
1 parent 594fde2 commit affea29

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

.github/workflows/test_auto_merge.yaml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@ jobs:
88
create-test-pr:
99
runs-on: ubuntu-latest
1010
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+
1119
- name: Checkout
1220
uses: actions/checkout@v4
1321
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 }}
1524
ref: auto-approve-merge
1625

1726
- name: Create test branch and file
@@ -27,18 +36,21 @@ jobs:
2736
echo "Test auto-merge at $(date)" > test-auto-merge.txt
2837
echo "This file can be deleted after testing" >> test-auto-merge.txt
2938
30-
# Configure git (as github-actions bot)
39+
# Configure git explicitly as github-actions bot
3140
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"
3342
34-
# Commit and push
43+
# Commit with explicit author
3544
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
3749
git push origin $BRANCH_NAME
3850
3951
- name: Create PR using GitHub API
4052
run: |
41-
# Create PR using gh CLI
53+
# The PR will be created by whatever token is used here
4254
PR_URL=$(gh pr create \
4355
--base auto-approve-merge \
4456
--head $BRANCH_NAME \
@@ -49,5 +61,16 @@ jobs:
4961
- Can be closed if auto-merge fails")
5062
5163
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'
5275
env:
53-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)