Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b6e8fef

Browse files
jsjoeioTinLe
authored andcommitted
refactor(ci): clean up npm workflows (coder#4786)
This extracst the publish on npm workflow from ci.yaml and adds a new workflow called `npm-beta.yaml`. Now we have three workflows that publish to npm. - `npm-beta.yaml` only runs on pushes and merges into `main` - `npm-dev.yaml` only runs on PRs into `main` with approval from code-server-reviewers team - `npm-brew.yaml` only runs on releases This should fix problems we had previously where anyone could open a PR and publish under the code-server namespace. It also separates out the workflows based on environment and when they should run.
1 parent 9bdc703 commit b6e8fef

File tree

4 files changed

+38
-17
lines changed

4 files changed

+38
-17
lines changed

‎.github/workflows/ci.yaml‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,6 @@ jobs:
177177
name: npm-package
178178
path: ./package.tar.gz
179179

180-
- name: Publish npm package with PR number and commit SHA
181-
run: yarn publish:npm
182-
env:
183-
ENVIRONMENT: "development"
184-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
185-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
186-
NPM_TAG: ${{ github.event.number }}
187-
PR_NUMBER_AND_COMMIT_SHA: ${{ github.event.number }}-${{ github.event.pull_request.head.sha }}
188-
189180
# TODO: cache building yarn --production
190181
# possibly 2m30s of savings(?)
191182
# this requires refactoring our release scripts

‎.github/workflows/npm-beta.yaml‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish on npm and tag with "beta"
2+
3+
on:
4+
# Shows the manual trigger in GitHub UI
5+
# helpful as a back-up in case the GitHub Actions Workflow fails
6+
workflow_dispatch:
7+
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
# NOTE: this job requires curl, jq and yarn
14+
# All of them are included in ubuntu-latest.
15+
npm:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v2
19+
20+
- name: Publish npm package and tag "beta"
21+
run: yarn publish:npm
22+
env:
23+
ENVIRONMENT: "staging"
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
26+
NPM_TAG: "beta"
27+
# Since this only runs on a merge into main, we can't use github.event.number
28+
# so we instead use the word "beta" and the PR merge commit SHA
29+
PR_NUMBER_AND_COMMIT_SHA: beta-${{ github.sha }}

‎.github/workflows/npm-brew.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v2
1818

19-
- name: Publish npm package with PR number and commit SHA
19+
- name: Publish npm package and tag with "latest"
2020
run: yarn publish:npm
2121
env:
2222
ENVIRONMENT: "production"

‎.github/workflows/npm-dev.yaml‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
name: Publish on npm and tag with "beta"
1+
name: Publish on npm and tag with PR number
22

33
on:
44
# Shows the manual trigger in GitHub UI
55
# helpful as a back-up in case the GitHub Actions Workflow fails
66
workflow_dispatch:
77

8-
push:
8+
pull_request:
99
branches:
1010
- main
1111

1212
jobs:
1313
# NOTE: this job requires curl, jq and yarn
1414
# All of them are included in ubuntu-latest.
1515
npm:
16+
# This environment "npm" requires someone from
17+
# coder/code-server-reviewers to approve the PR before this job runs.
18+
environment: npm
1619
runs-on: ubuntu-latest
1720
steps:
1821
- uses: actions/checkout@v2
1922

2023
- name: Run ./ci/steps/publish-npm.sh
2124
run: yarn publish:npm
2225
env:
23-
ENVIRONMENT: "staging"
26+
ENVIRONMENT: "development"
2427
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2528
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
26-
NPM_TAG: "beta"
27-
# Since this only runs on a merge into main, we can't use github.event.number
28-
# so we instead use the word "beta" and the PR merge commit SHA
29-
PR_NUMBER_AND_COMMIT_SHA: beta-${{ github.sha }}
29+
NPM_TAG: ${{ github.event.number }}
30+
PR_NUMBER_AND_COMMIT_SHA: ${{ github.event.number }}-${{ github.event.pull_request.head.sha }}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /