Skip to content

Commit 5757ba6

Browse files
committed
ci: Enable forks to run CI
All steps that require tokens are optional for forks, and will be skipped if the owner is not "coder".
1 parent c1ff537 commit 5757ba6

File tree

3 files changed

+18
-109
lines changed

3 files changed

+18
-109
lines changed

.github/workflows/chromatic.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ jobs:
3333
with:
3434
buildScriptName: "storybook:build"
3535
exitOnceUploaded: true
36-
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
36+
# Chromatic states its fine to make this token public. See:
37+
# https://www.chromatic.com/docs/github-actions#forked-repositories
38+
projectToken: 695c25b6cb65
3739
workingDir: "./site"
3840

3941
# This is a separate step for mainline only that auto accepts and changes
@@ -48,5 +50,5 @@ jobs:
4850
with:
4951
autoAcceptChanges: true
5052
buildScriptName: "storybook:build"
51-
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
53+
projectToken: 695c25b6cb65
5254
workingDir: "./site"

.github/workflows/coder-test-stability.yaml

Lines changed: 0 additions & 98 deletions
This file was deleted.

.github/workflows/coder.yaml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
tags:
99
- "*"
1010

11+
# This is required so CI can run on forked repositories too!
12+
pull_request_target:
13+
branches:
14+
- "*"
15+
1116
pull_request:
1217
branches:
1318
- "*"
@@ -178,7 +183,7 @@ jobs:
178183
-timeout=3m -count=$GOCOUNT -short -failfast
179184

180185
- name: Upload DataDog Trace
181-
if: (success() || failure()) && github.actor != 'dependabot[bot]'
186+
if: (success() || failure()) && github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
182187
env:
183188
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
184189
DD_DATABASE: fake
@@ -187,7 +192,7 @@ jobs:
187192
run: go run scripts/datadog-cireport/main.go gotests.xml
188193

189194
- uses: codecov/codecov-action@v2
190-
if: github.actor != 'dependabot[bot]'
195+
if: github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
191196
with:
192197
token: ${{ secrets.CODECOV_TOKEN }}
193198
files: ./gotests.coverage
@@ -264,25 +269,25 @@ jobs:
264269
-count=1 -parallel=2 -race -failfast
265270

266271
- name: Upload DataDog Trace
267-
if: (success() || failure()) && github.actor != 'dependabot[bot]'
272+
if: (success() || failure()) && github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
268273
env:
269274
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
270275
DD_DATABASE: postgresql
271276
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
272277
run: go run scripts/datadog-cireport/main.go gotests.xml
273278

274279
- uses: codecov/codecov-action@v2
275-
if: github.actor != 'dependabot[bot]'
280+
if: github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
276281
with:
277282
token: ${{ secrets.CODECOV_TOKEN }}
278283
files: ./gotests.coverage
279284
flags: unittest-go-${{ matrix.os }}
280-
fail_ci_if_error: true
285+
fail_ci_if_error: ${{ github.repository_owner == 'coder' }}
281286

282287
deploy:
283288
name: "deploy"
284289
runs-on: ubuntu-latest
285-
if: github.ref == 'refs/heads/main'
290+
if: github.ref == 'refs/heads/main' && github.repository_owner == 'coder'
286291
permissions:
287292
contents: read
288293
id-token: write
@@ -391,15 +396,15 @@ jobs:
391396
working-directory: site
392397

393398
- uses: codecov/codecov-action@v2
394-
if: github.actor != 'dependabot[bot]'
399+
if: github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
395400
with:
396401
token: ${{ secrets.CODECOV_TOKEN }}
397402
files: ./site/coverage/lcov.info
398403
flags: unittest-js
399404
fail_ci_if_error: true
400405

401406
- name: Upload DataDog Trace
402-
if: (success() || failure()) && github.actor != 'dependabot[bot]'
407+
if: (success() || failure()) && github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
403408
env:
404409
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
405410
DD_CATEGORY: unit
@@ -483,7 +488,7 @@ jobs:
483488
working-directory: site
484489

485490
- name: Upload DataDog Trace
486-
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux'
491+
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux' && github.repository_owner == 'coder'
487492
env:
488493
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
489494
DD_CATEGORY: e2e

0 commit comments

Comments
 (0)