Skip to content

Commit

Permalink
Merge pull request #12 from Frederick888/fix-pub-fork into master
Browse files Browse the repository at this point in the history
* fix-pub-fork:
  ci: Bump to actions/checkout@v4
  docs: Bump to actions/checkout@v4
  ci: Switch to pull_request_target
  docs: Suggest using pull_request_target
  fix: Use gh pr checkout instead of relying on actions/checkout
  • Loading branch information
Frederick888 committed Nov 1, 2023
2 parents b8fc57f + 95c89db commit 61ab537
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gh-ph.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Pull request history

on:
pull_request:
pull_request_target:

permissions:
contents: read
Expand All @@ -17,7 +17,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: Frederick888/gh-ph@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
create_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Conventional Commit Changelog
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Then add the fences to your pull request templates, and finally set up a job as

```yaml
on:
pull_request:
pull_request_target:

permissions:
contents: read
Expand All @@ -50,7 +50,7 @@ jobs:
name: Add commit history to pull request description
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 100
- run: |
Expand All @@ -61,8 +61,6 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
_Note_: [`GITHUB_TOKEN`](https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/) (and [secrets](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#using-secrets-in-a-workflow)) does not work on PRs from public forks. Private repositories can consider [sending write tokens to workflows from pull requests](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#enabling-workflows-for-forks-of-private-repositories).

# Configuration
Default history format can be configured via environment variable [`GH_PH_HISTORY_FORMAT`](https://github.com/Frederick888/gh-ph/blob/1a9fe6f74a6067559885246a67f1d1df9366252c/gh-ph#L12) ([`with.format`](https://github.com/Frederick888/gh-ph/blob/1a9fe6f74a6067559885246a67f1d1df9366252c/action.yml#L8-L11) in Actions).
Expand Down
5 changes: 1 addition & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ runs:
steps:
- run: |
git checkout "$GITHUB_BASE_REF"
if ! git checkout "$GITHUB_HEAD_REF"; then
git checkout "${GITHUB_REF/refs\//}^2"
git checkout -b "$GITHUB_HEAD_REF"
fi
gh pr checkout "$GH_PH_PULL_REQUEST_ID"
printf 'y' | \
GH_PH_PAGER='cat' \
GH_PH_DEBUG='${{ inputs.debug }}' \
Expand Down

0 comments on commit 61ab537

Please sign in to comment.