Skip to content

Commit 0bf4fe1

Browse files
authored
Fix update-readme workflow for protected main branch (#174)
* Fix update-readme workflow for protected main branch - Only push changes on pull_request events (where github.head_ref exists) - Fail with helpful message if README is out of date on main push * Update README.md
1 parent 98383d4 commit 0bf4fe1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.github/workflows/update-readme.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,14 @@ jobs:
4040
fi
4141
4242
- name: Push changes
43-
if: env.commit_status == 'committed'
43+
if: env.commit_status == 'committed' && github.event_name == 'pull_request'
4444
uses: ad-m/github-push-action@master
4545
with:
4646
github_token: ${{ secrets.GITHUB_TOKEN }}
4747
branch: ${{ github.head_ref }}
48+
49+
- name: Fail if README is out of date on main
50+
if: env.commit_status == 'committed' && github.event_name == 'push'
51+
run: |
52+
echo "README.md is out of date. Please run 'uvx --with . markdown-code-runner README.md' and commit the changes."
53+
exit 1

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ positional arguments:
9999

100100
options:
101101
-h, --help show this help message and exit
102-
-p, --port PORT SSH port.
103-
-i, --id_rsa ID_RSA Specify the private ssh key to use.
102+
-p PORT, --port PORT SSH port.
103+
-i ID_RSA, --id_rsa ID_RSA
104+
Specify the private ssh key to use.
104105
--rsync-get-flags Display the default rsync flags that are used for
105106
backup. If using remote drive over SSH, --compress
106107
will be added.

0 commit comments

Comments
 (0)