Skip to content

Commit

Permalink
Add dry-run input (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbhmr authored Mar 27, 2023
1 parent 3912134 commit aef2554
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ jobs:
# For now, you'll need to manually specify a GitHub token until we
# solve #2. The x: prefix is a dummy username.
token: x:${{ secrets.GITHUB_TOKEN }}
dry-run: ${{ github.ref != 'main' }}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ one of your GitHub Actions workflows.
is `Update wiki ${{ github.sha }}`. You probably don't need to change this,
since this only applies if you look _really closely_ in your wiki.

- **`dry-run`:** Whether or not to actually attempt to push changes back to the
wiki itself. If this is set to `true`, we instead print the remote URL and do
not push to the remote wiki. The default is `false`. This is useful for
testing.

## Alternatives

There are quite a few GitHub wiki publishing actions on the [GitHub Actions
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ inputs:
applies if you look really closely in your wiki.
required: true
default: Update wiki ${{ github.sha }}
dry-run:
description: >-
Whether or not to actually attempt to push changes back to the wiki
itself. If this is set to true, we instead print the remote URL and do not
push to the remote wiki. The default is false. This is useful for testing.
required: true
default: false
runs:
using: composite
steps:
Expand All @@ -41,3 +48,4 @@ runs:
INPUT_TOKEN: ${{ inputs.token }}
INPUT_PATH: ${{ inputs.path }}
INPUT_COMMIT_MESSAGE: ${{ inputs.commit-message }}
INPUT_DRY_RUN: ${{ inputs.dry-run }}
8 changes: 7 additions & 1 deletion src/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ git reset origin/master

git add --all
git commit -m "$INPUT_COMMIT_MESSAGE"
git push -u origin master

if [[ $INPUT_DRY_RUN == true ]]; then
git remote show origin
git show
else
git push -u origin master
fi

rm -rf ./.git

0 comments on commit aef2554

Please # to comment.