Skip to content

Commit aebfc67

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 aebfc67

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

.github/workflows/chromatic.yaml

+4-2
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
-timeout=15m -count=$GOCOUNT -race -short -failfast
7575

7676
- name: Upload DataDog Trace
77-
if: (success() || failure()) && github.actor != 'dependabot[bot]'
77+
if: (success() || failure()) && github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
7878
env:
7979
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
8080
DD_DATABASE: fake
@@ -90,7 +90,7 @@ jobs:
9090
-count=$GOCOUNT -race -parallel=2 -failfast
9191

9292
- name: Upload DataDog Trace
93-
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux'
93+
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux' && github.repository_owner == 'coder'
9494
env:
9595
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
9696
DD_DATABASE: postgresql

.github/workflows/coder.yaml

+11-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ on:
88
tags:
99
- "*"
1010

11-
pull_request:
11+
# This is required so CI can run on forked repositories too!
12+
pull_request_target:
1213
branches:
1314
- "*"
1415

@@ -178,7 +179,7 @@ jobs:
178179
-timeout=3m -count=$GOCOUNT -short -failfast
179180

180181
- name: Upload DataDog Trace
181-
if: (success() || failure()) && github.actor != 'dependabot[bot]'
182+
if: (success() || failure()) && github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
182183
env:
183184
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
184185
DD_DATABASE: fake
@@ -187,7 +188,7 @@ jobs:
187188
run: go run scripts/datadog-cireport/main.go gotests.xml
188189

189190
- uses: codecov/codecov-action@v2
190-
if: github.actor != 'dependabot[bot]'
191+
if: github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
191192
with:
192193
token: ${{ secrets.CODECOV_TOKEN }}
193194
files: ./gotests.coverage
@@ -264,25 +265,25 @@ jobs:
264265
-count=1 -parallel=2 -race -failfast
265266

266267
- name: Upload DataDog Trace
267-
if: (success() || failure()) && github.actor != 'dependabot[bot]'
268+
if: (success() || failure()) && github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
268269
env:
269270
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
270271
DD_DATABASE: postgresql
271272
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
272273
run: go run scripts/datadog-cireport/main.go gotests.xml
273274

274275
- uses: codecov/codecov-action@v2
275-
if: github.actor != 'dependabot[bot]'
276+
if: github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
276277
with:
277278
token: ${{ secrets.CODECOV_TOKEN }}
278279
files: ./gotests.coverage
279280
flags: unittest-go-${{ matrix.os }}
280-
fail_ci_if_error: true
281+
fail_ci_if_error: ${{ github.repository_owner == 'coder' }}
281282

282283
deploy:
283284
name: "deploy"
284285
runs-on: ubuntu-latest
285-
if: github.ref == 'refs/heads/main'
286+
if: github.ref == 'refs/heads/main' && github.repository_owner == 'coder'
286287
permissions:
287288
contents: read
288289
id-token: write
@@ -391,15 +392,15 @@ jobs:
391392
working-directory: site
392393

393394
- uses: codecov/codecov-action@v2
394-
if: github.actor != 'dependabot[bot]'
395+
if: github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
395396
with:
396397
token: ${{ secrets.CODECOV_TOKEN }}
397398
files: ./site/coverage/lcov.info
398399
flags: unittest-js
399400
fail_ci_if_error: true
400401

401402
- name: Upload DataDog Trace
402-
if: (success() || failure()) && github.actor != 'dependabot[bot]'
403+
if: (success() || failure()) && github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
403404
env:
404405
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
405406
DD_CATEGORY: unit
@@ -483,7 +484,7 @@ jobs:
483484
working-directory: site
484485

485486
- name: Upload DataDog Trace
486-
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux'
487+
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux' && github.repository_owner == 'coder'
487488
env:
488489
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
489490
DD_CATEGORY: e2e

0 commit comments

Comments
 (0)