Skip to content

Commit 43c8df6

Browse files
committed
[ci] Fix contribution message workflow
1 parent 84757ce commit 43c8df6

2 files changed

Lines changed: 71 additions & 26 deletions

File tree

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,23 @@
1-
name: Post contribution message in pull request
1+
name: Collect PR metadata for contribution message
22
on:
33
pull_request:
44
types: [opened, reopened]
55

6-
permissions:
7-
contents: write
8-
pull-requests: write
9-
106
jobs:
11-
post_contribution_message:
7+
collect_pr_metadata:
128
runs-on: ubuntu-latest
139
steps:
14-
- name: Checkout repository
15-
uses: actions/checkout@v6
16-
17-
- name: Setup Python
18-
uses: actions/setup-python@v5
19-
with:
20-
python-version: "3.13"
21-
22-
- name: Install dependencies
10+
- name: Save PR metadata
2311
run: |
24-
pip install requests PyGithub
12+
mkdir -p pr-metadata
13+
echo "${{ github.event.pull_request.number }}" > pr-metadata/pr_number
14+
echo "${{ github.event.pull_request.user.login }}" > pr-metadata/commit_author
15+
echo "${{ github.event.pull_request.head.repo.owner.login }}" > pr-metadata/fork_author
16+
echo "${{ github.event.pull_request.head.repo.name }}" > pr-metadata/fork_repo
17+
echo "${{ github.event.pull_request.head.ref }}" > pr-metadata/fork_branch
2518
26-
- name: Run post contribution message script
27-
env:
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29-
PR_NUMBER: ${{ github.event.pull_request.number }}
30-
COMMIT_AUTHOR: ${{ github.event.pull_request.user.login }}
31-
FORK_AUTHOR: ${{ github.event.pull_request.head.repo.owner.login }}
32-
FORK_REPO: ${{ github.event.pull_request.head.repo.name }}
33-
FORK_BRANCH: ${{ github.event.pull_request.head.ref }}
34-
run: |
35-
python scripts/post-contribution-message.py
19+
- name: Upload PR metadata
20+
uses: actions/upload-artifact@v4
21+
with:
22+
name: pr-metadata
23+
path: pr-metadata/
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Post contribution message in pull request
2+
on:
3+
workflow_run:
4+
workflows: ["Collect PR metadata for contribution message"]
5+
types:
6+
- completed
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
post_contribution_message:
14+
runs-on: ubuntu-latest
15+
if: >
16+
github.event.workflow_run.event == 'pull_request' &&
17+
github.event.workflow_run.conclusion == 'success'
18+
steps:
19+
- name: Download PR metadata artifact
20+
uses: actions/download-artifact@v4
21+
with:
22+
name: pr-metadata
23+
path: pr-metadata/
24+
github-token: ${{ secrets.GITHUB_TOKEN }}
25+
run-id: ${{ github.event.workflow_run.id }}
26+
27+
- name: Read PR metadata
28+
id: pr-metadata
29+
run: |
30+
echo "pr_number=$(cat pr-metadata/pr_number)" >> $GITHUB_OUTPUT
31+
echo "commit_author=$(cat pr-metadata/commit_author)" >> $GITHUB_OUTPUT
32+
echo "fork_author=$(cat pr-metadata/fork_author)" >> $GITHUB_OUTPUT
33+
echo "fork_repo=$(cat pr-metadata/fork_repo)" >> $GITHUB_OUTPUT
34+
echo "fork_branch=$(cat pr-metadata/fork_branch)" >> $GITHUB_OUTPUT
35+
36+
- name: Checkout repository
37+
uses: actions/checkout@v6
38+
39+
- name: Setup Python
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: "3.13"
43+
44+
- name: Install dependencies
45+
run: |
46+
pip install requests PyGithub
47+
48+
- name: Run post contribution message script
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
PR_NUMBER: ${{ steps.pr-metadata.outputs.pr_number }}
52+
COMMIT_AUTHOR: ${{ steps.pr-metadata.outputs.commit_author }}
53+
FORK_AUTHOR: ${{ steps.pr-metadata.outputs.fork_author }}
54+
FORK_REPO: ${{ steps.pr-metadata.outputs.fork_repo }}
55+
FORK_BRANCH: ${{ steps.pr-metadata.outputs.fork_branch }}
56+
run: |
57+
python scripts/post-contribution-message.py

0 commit comments

Comments
 (0)