Skip to content

Commit 770d212

Browse files
authored
ci: Enable forks to run CI (#910)
* 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". * Empty commit to force CI
1 parent 23f9891 commit 770d212

File tree

4 files changed

+22
-124
lines changed

4 files changed

+22
-124
lines changed

.github/workflows/chromatic.yaml

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
# by storing snapshots.
55
#
66
# SEE: https://www.chromatic.com/docs/ci
7-
name: "Chromatic"
7+
name: chromatic
88

99
# Chromatic works best with push events, not pull_request or other event types.
1010
on: push
1111

1212
jobs:
13-
chromatic-deployment:
13+
deploy:
1414
# REMARK: this is only used to build storybook and deploy it to Chromatic.
1515
runs-on: ubuntu-latest
1616

@@ -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

-98
This file was deleted.

.github/workflows/coder.yaml

+9-22
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@ name: coder
22

33
on:
44
push:
5-
branches:
6-
- main
7-
- "release/*"
8-
tags:
9-
- "*"
10-
11-
pull_request:
12-
branches:
13-
- "*"
145

156
workflow_dispatch:
167

@@ -178,7 +169,7 @@ jobs:
178169
-timeout=3m -count=$GOCOUNT -short -failfast
179170

180171
- name: Upload DataDog Trace
181-
if: (success() || failure()) && github.actor != 'dependabot[bot]'
172+
if: (success() || failure()) && github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
182173
env:
183174
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
184175
DD_DATABASE: fake
@@ -187,7 +178,7 @@ jobs:
187178
run: go run scripts/datadog-cireport/main.go gotests.xml
188179

189180
- uses: codecov/codecov-action@v2
190-
if: github.actor != 'dependabot[bot]'
181+
if: github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
191182
with:
192183
token: ${{ secrets.CODECOV_TOKEN }}
193184
files: ./gotests.coverage
@@ -264,25 +255,25 @@ jobs:
264255
-count=1 -parallel=2 -race -failfast
265256

266257
- name: Upload DataDog Trace
267-
if: (success() || failure()) && github.actor != 'dependabot[bot]'
258+
if: (success() || failure()) && github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
268259
env:
269260
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
270261
DD_DATABASE: postgresql
271262
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
272263
run: go run scripts/datadog-cireport/main.go gotests.xml
273264

274265
- uses: codecov/codecov-action@v2
275-
if: github.actor != 'dependabot[bot]'
266+
if: github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
276267
with:
277268
token: ${{ secrets.CODECOV_TOKEN }}
278269
files: ./gotests.coverage
279-
flags: unittest-go-${{ matrix.os }}
270+
flags: unittest-go-postgres-${{ matrix.os }}
280271
fail_ci_if_error: true
281272

282273
deploy:
283274
name: "deploy"
284275
runs-on: ubuntu-latest
285-
if: github.ref == 'refs/heads/main'
276+
if: github.ref == 'refs/heads/main' && github.repository_owner == 'coder'
286277
permissions:
287278
contents: read
288279
id-token: write
@@ -391,15 +382,15 @@ jobs:
391382
working-directory: site
392383

393384
- uses: codecov/codecov-action@v2
394-
if: github.actor != 'dependabot[bot]'
385+
if: github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
395386
with:
396387
token: ${{ secrets.CODECOV_TOKEN }}
397388
files: ./site/coverage/lcov.info
398389
flags: unittest-js
399390
fail_ci_if_error: true
400391

401392
- name: Upload DataDog Trace
402-
if: (success() || failure()) && github.actor != 'dependabot[bot]'
393+
if: (success() || failure()) && github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
403394
env:
404395
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
405396
DD_CATEGORY: unit
@@ -413,10 +404,6 @@ jobs:
413404
matrix:
414405
os:
415406
- ubuntu-latest
416-
- macos-latest
417-
# TODO: Get `make build` running on Windows 2022
418-
# https://github.com/coder/coder/issues/384
419-
# - windows-2022
420407
steps:
421408
- uses: actions/checkout@v3
422409

@@ -483,7 +470,7 @@ jobs:
483470
working-directory: site
484471

485472
- name: Upload DataDog Trace
486-
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux'
473+
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux' && github.repository_owner == 'coder'
487474
env:
488475
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
489476
DD_CATEGORY: e2e

codecov.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ comment:
66

77
coverage:
88
notify:
9+
flags:
10+
# Wait to notify until coverage has properly been reported.
11+
# This can prevent incorrect statuses.
12+
- unittest-go-ubuntu-latest
13+
- unittest-go-postgres-ubuntu-latest
14+
- unittest-go-macos-latest
15+
- unittest-go-windows-2022
916
slack:
1017
default:
1118
url: secret:v1::ALa1/e2X+k36fPseab5D7+kBFc9bJyIoIQioD0IMA5jr+0HXVpBRNDCHZhHjCdGc67yff6PPixPEOLwEZpxC37rM23RBZOYlqAq9A5e0MeZVlEoVq19aOYN4Xel17hMJ6GGm7n17wrYpCpcvlVSqNrN0+cr3guVDyG10kQyfh2Y=

0 commit comments

Comments
 (0)