Skip to content

Commit

Permalink
Attempt to solve write access as a PR workflow from forks
Browse files Browse the repository at this point in the history
  • Loading branch information
fritx committed Jan 22, 2024
1 parent 6aea8d8 commit b47b5b2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:

runs-on: ${{ matrix.os }}

permissions:
contents: write

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -37,5 +40,14 @@ jobs:
run: npm run test:cov

- name: Update Coverage Badge
if: ${{ matrix.os == 'ubuntu-22.04' && matrix.node-version == 18 }}
# Is there a way to tell if a PR is from a forked repository? #26829
# https://github.com/orgs/community/discussions/26829#discussioncomment-3253580
if: >-
matrix.os == 'ubuntu-22.04' && matrix.node-version == 18 && ((
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
) || (
github.event_name == 'pull_request_target' &&
github.event.pull_request.head.repo.full_name != github.repository
))
uses: we-cli/coverage-badge-action@main

0 comments on commit b47b5b2

Please sign in to comment.