|
| 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