Skip to content

Commit

Permalink
Update workflow for PRs (#45)
Browse files Browse the repository at this point in the history
* Streamline the difference check

* Make doc updates support PRs

* Experiment
  • Loading branch information
webbnh authored Nov 4, 2024
1 parent 77a8eee commit c728508
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/reusable_workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,23 @@ jobs:
- name: Determine diff
run: |
set +e
diff README.md README_TMP.md > arcaflow-docsgen.diff
set -e
echo "README_DIFF=$(cat arcaflow-docsgen.diff | wc -l)" >> $GITHUB_ENV
echo "README_DIFF=$(cmp -s README.md README_TMP.md ; echo $?)" >> $GITHUB_ENV
- name: Update README.md if necessary
if: env.README_DIFF != 0 && !github.ref_protected
- name: Update README.md if appropriate
# The github.head_ref variable is only available for pull requests,
# however, we probably shouldn't be updating the branch for anything
# which isn't a PR, anyway!
if: env.README_DIFF == 1 && github.event_name == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_EMAIL: [email protected]
GH_USERNAME: arcabot
run: |
mv README_TMP.md README.md
git config --global user.name $GH_USERNAME
git config --global user.email $GH_EMAIL
git add README.md
git commit -m 'Automatic update of README.md by arcaflow-docsgen arcabot'
git push
git fetch origin ${{ github.head_ref }}
git checkout -f ${{ github.head_ref }}
mv README_TMP.md README.md
git commit -m 'Automatic update of README.md by arcaflow-docsgen arcabot' README.md
git push origin HEAD:${{ github.head_ref }}
git checkout -f refs/remotes/pull/${{ github.ref_name }}

0 comments on commit c728508

Please sign in to comment.