Update Phan stubs #7
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: Update Phan stubs | |
on: | |
workflow_dispatch: | |
concurrency: | |
group: update-phan-stubs-${{ github.ref }} | |
env: | |
GIT_AUTHOR_NAME: matticbot | |
GIT_AUTHOR_EMAIL: [email protected] | |
GIT_COMMITTER_NAME: matticbot | |
GIT_COMMITTER_EMAIL: [email protected] | |
jobs: | |
update-stubs: | |
name: Update stubs | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Update stubs | |
run: tools/stubs/update-stubs.sh | |
- name: Check for changes | |
id: changes | |
run: | | |
if git diff --exit-code; then | |
echo "No changes" | |
echo "needed=false" >> "$GITHUB_OUTPUT" | |
elif git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin update/phan-custom-stubs >/dev/null; then | |
TMP=$( git -c core.quotepath=off diff --name-only ) | |
mapfile -t FILES <<<"$TMP" | |
if git diff --quiet --exit-code origin/update/phan-custom-stubs "${FILES[@]}"; then | |
echo "Branch already exists and is up to date with these changes" | |
echo "needed=false" >> "$GITHUB_OUTPUT" | |
else | |
echo "has-branch=true" >> "$GITHUB_OUTPUT" | |
echo "needed=true" >> "$GITHUB_OUTPUT" | |
fi | |
else | |
echo "has-branch=false" >> "$GITHUB_OUTPUT" | |
echo "needed=true" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Create commit and PR | |
if: steps.changes.outputs.needed == 'true' && steps.changes.outputs.has-branch == 'false' | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
git checkout -b update/phan-custom-stubs | |
git commit -am 'phan: Update custom stubs' | |
git push origin HEAD | |
gh pr create --title 'phan: Update custom stubs' --body 'This is an automatic update generated by a GitHub Action. If closed it will be recreated the next time the action runs.' --label '[Pri] Normal' --label '[Type] Janitorial' --label '[Status] Needs Review' | |
- name: Update existing branch | |
if: steps.changes.outputs.needed == 'true' && steps.changes.outputs.has-branch == 'true' | |
run: | | |
git commit -am 'phan: Update custom stubs' | |
SHA=$( git rev-parse HEAD ) | |
git checkout update/phan-custom-stubs | |
git reset --hard "$SHA" | |
git push --force-with-lease origin HEAD |