Skip to content

Commit

Permalink
Don't update license report in PR from a forked repository
Browse files Browse the repository at this point in the history
  • Loading branch information
masutaka committed Oct 29, 2024
1 parent 009ab4f commit 2b0e1e7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ jobs:
env:
LICENSE_REPORT: docs/packages-license.md
steps:
- name: Check if running in a fork
id: fork-check
run: echo "is_fork=${{ github.event.pull_request.head.repo.fork }}" >> "$GITHUB_OUTPUT"
- uses: actions/create-github-app-token@v1
if: steps.fork-check.outputs.is_fork != 'true'
id: app-token
with:
app-id: ${{ vars.CI_TRIGGER_APP_ID }}
private-key: ${{ secrets.CI_TRIGGER_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ steps.app-token.outputs.token }}
token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
# To make the success of this job a prerequisite for merging into the main branch,
# set a filter here instead of on: to determine whether or not to proceed to the next step.
- name: Cache dependency files
Expand Down Expand Up @@ -71,7 +75,8 @@ jobs:
run: license_finder report --format=markdown | tail -n +2 > "$LICENSE_REPORT"
- name: Commit license report and push
if: |
steps.determine.outputs.files_changed == 'true'
steps.fork-check.outputs.is_fork != 'true'
&& steps.determine.outputs.files_changed == 'true'
&& github.ref_name != github.event.repository.default_branch
run: |
git config user.name 'github-actions[bot]'
Expand Down

0 comments on commit 2b0e1e7

Please sign in to comment.