Skip to content

Commit 5e5c5ce

Browse files
Add minimal GitHub Actions permissions and coverage upload workflow
Co-authored-by: maciej.jastrzebski <maciej.jastrzebski@callstack.com>
1 parent 3ba3242 commit 5e5c5ce

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
pull_request:
66
branches: ['**']
77

8+
# Set minimal permissions by default
9+
permissions:
10+
contents: read
11+
812
concurrency:
913
group: ${{ github.workflow }}-${{ github.ref }}
1014
cancel-in-progress: ${{ !contains(github.ref, 'main')}}
@@ -13,6 +17,8 @@ jobs:
1317
install-cache-deps:
1418
runs-on: ubuntu-latest
1519
name: Install and Cache deps
20+
permissions:
21+
contents: read
1622
steps:
1723
- name: Checkout
1824
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -24,6 +30,8 @@ jobs:
2430
needs: [install-cache-deps]
2531
runs-on: ubuntu-latest
2632
name: Lint
33+
permissions:
34+
contents: read
2735
steps:
2836
- name: Checkout
2937
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -38,6 +46,8 @@ jobs:
3846
needs: [install-cache-deps]
3947
runs-on: ubuntu-latest
4048
name: Typecheck
49+
permissions:
50+
contents: read
4151
steps:
4252
- name: Checkout
4353
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -52,6 +62,8 @@ jobs:
5262
needs: [install-cache-deps]
5363
runs-on: ubuntu-latest
5464
name: Test
65+
permissions:
66+
contents: read
5567
steps:
5668
- name: Checkout
5769
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -62,6 +74,32 @@ jobs:
6274
- name: Test
6375
run: yarn test:ci:coverage
6476

77+
- name: Upload coverage reports
78+
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
79+
with:
80+
name: coverage-reports
81+
path: coverage/
82+
retention-days: 1
83+
84+
# Separate job for codecov upload that only runs on trusted events
85+
upload-coverage:
86+
needs: [test]
87+
runs-on: ubuntu-latest
88+
name: Upload Coverage
89+
# Only run on push to main (trusted event) to avoid exposing secrets to forks
90+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
91+
permissions:
92+
contents: read
93+
steps:
94+
- name: Checkout
95+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
96+
97+
- name: Download coverage reports
98+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
99+
with:
100+
name: coverage-reports
101+
path: coverage/
102+
65103
- name: Upload coverage to Codecov
66104
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
67105
env:
@@ -71,6 +109,8 @@ jobs:
71109
needs: [install-cache-deps]
72110
runs-on: ubuntu-latest
73111
name: Test React 18
112+
permissions:
113+
contents: read
74114
steps:
75115
- name: Checkout
76116
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

.github/workflows/example-apps.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
branches: ['**']
99
paths: ['examples/**']
1010

11+
# Set minimal permissions by default
12+
permissions:
13+
contents: read
14+
1115
jobs:
1216
test-example:
1317
strategy:
@@ -17,6 +21,8 @@ jobs:
1721
name: Test Example
1822
runs-on: ubuntu-latest
1923
timeout-minutes: 10
24+
permissions:
25+
contents: read
2026
steps:
2127
- name: Checkout
2228
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

.github/workflows/website.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
branches: ['**']
99
paths: ['website/**']
1010

11+
# Set minimal permissions by default
12+
permissions:
13+
contents: read
14+
1115
concurrency:
1216
group: ${{ github.workflow }}-${{ github.ref }}
1317
cancel-in-progress: ${{ !contains(github.ref, 'main')}}
@@ -16,6 +20,8 @@ jobs:
1620
test:
1721
runs-on: ubuntu-latest
1822
name: Test Website
23+
permissions:
24+
contents: read
1925
steps:
2026
- name: Checkout
2127
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -28,8 +34,13 @@ jobs:
2834

2935
deploy:
3036
name: Deploy to GitHub Pages
37+
# Only run on push to main (trusted event) - secrets are safe here
3138
if: github.ref == 'refs/heads/main'
3239
runs-on: ubuntu-latest
40+
permissions:
41+
contents: read
42+
pages: write
43+
id-token: write
3344
steps:
3445
- name: Checkout
3546
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

0 commit comments

Comments
 (0)