CI: Add GitHub Action to append installation instructions to PRs #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR Install Note | |
on: | |
pull_request: | |
types: [opened, reopened, ready_for_review] | |
jobs: | |
add-install-note: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Add PR install note | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PR_NUMBER: ${{ github.event.pull_request.number }} | |
run: | | |
PR_BODY=$(gh pr view $PR_NUMBER --json body -q .body) | |
FORK_NAME=$(gh pr view $PR_NUMBER --json headRepositoryOwner -q .headRepositoryOwner.login) | |
PR_BRANCH=$(gh pr view $PR_NUMBER --json headRefName -q .headRefName) | |
REPO_OWNER=${FORK_NAME:-projectmesa} | |
INSTALL_NOTE=$(cat << EOF | |
You can install this PR branch with: | |
\`\`\` | |
pip install -U -e git+https://github.com/${REPO_OWNER}/mesa@${PR_BRANCH}#egg=mesa | |
\`\`\` | |
EOF | |
) | |
NEW_PR_BODY="${PR_BODY}${INSTALL_NOTE}" | |
gh pr edit $PR_NUMBER --body "$NEW_PR_BODY" |