Skip to content
This repository was archived by the owner on Aug 18, 2025. It is now read-only.

Commit 1ab1bbe

Browse files
author
Jonathan Yu
authored
chore: build and preview updates (#189)
* Run linting for push events to the default branch, as well as pull requests targeting the default branch * Remove obsolete (unused) deploy workflow * Reuse Vercel preview deploy scripts from cdr/m * Cache Node.js dependencies * Upgrade Node.js from 10 -> 12 for preview deployment * Upgrade actions/setup-node from v1 to v2 * Use ubuntu-20.04 instead of ubuntu-latest to avoid build warning * Add a comment with links and information for the preview
1 parent ef655e9 commit 1ab1bbe

File tree

4 files changed

+86
-111
lines changed

4 files changed

+86
-111
lines changed

.github/ci/deploy.sh

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

.github/workflows/ci.yaml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,37 @@
11
name: Quality
2-
on: push
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
workflow_dispatch:
310
jobs:
411
lint:
512
name: Lint
6-
runs-on: ubuntu-latest
13+
runs-on: ubuntu-20.04
714
steps:
8-
- uses: actions/checkout@v2
9-
- name: Use Node.js 12.x
10-
uses: actions/setup-node@v1
15+
- name: Cancel Previous Runs
16+
if: github.ref != 'refs/heads/master'
17+
uses: styfle/cancel-workflow-action@0.8.0
18+
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
22+
- name: Cache Node Modules
23+
uses: actions/cache@v2
24+
with:
25+
path: "/node_modules"
26+
key: node-${{ hashFiles('yarn.lock') }}
27+
28+
- name: Install Node.js
29+
uses: actions/setup-node@v2
1130
with:
1231
node-version: 12.x
13-
- name: Install node_modules
32+
33+
- name: Install Node Modules
1434
run: yarn
35+
1536
- name: Lint
1637
run: yarn lint

.github/workflows/deploy.yaml

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

.github/workflows/preview.yaml

Lines changed: 59 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,77 @@
1-
name: Deploy (Preview)
1+
name: Preview
22
on:
3-
push:
3+
pull_request:
44
branches:
5-
- "**"
6-
- "!master"
5+
- master
76
jobs:
87
preview:
98
name: Preview
10-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-20.04
1110
steps:
12-
- name: Checkout Mono
11+
- name: Cancel Previous Runs
12+
uses: styfle/cancel-workflow-action@0.8.0
13+
14+
- name: Checkout m
1315
uses: actions/checkout@v2
1416
with:
1517
repository: cdr/m
1618
ref: refs/heads/master
1719
token: ${{ secrets.GH_ACCESS_TOKEN }}
1820
submodules: true
1921
fetch-depth: 0
20-
- name: Checkout Docs
21-
run: git fetch && git checkout ${GITHUB_SHA}
22+
23+
- name: Checkout docs
24+
run: |
25+
git fetch
26+
git checkout "${{ github.head_ref }}"
2227
working-directory: ./product/coder.com/site/docs
23-
- name: Setup Node
24-
uses: actions/setup-node@v1
25-
- name: Deploy
26-
run: ./product/coder.com/site/docs/.github/ci/deploy.sh
28+
29+
- name: Install Node.js
30+
uses: actions/setup-node@v2
31+
with:
32+
node-version: 12.x
33+
34+
- name: Cache Node Modules
35+
uses: actions/cache@v2
36+
with:
37+
path: "/node_modules"
38+
key: node-${{ hashFiles('yarn.lock') }}
39+
40+
- name: Create Deployment
41+
id: deployment
42+
run: ./ci/scripts/github_deployment.sh create
2743
env:
2844
GITHUB_TOKEN: ${{ github.token }}
29-
GITHUB_REF: ${{ github.ref }}
30-
GITHUB_REPOSITORY: ${{ github.repository }}
31-
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
45+
DEPLOY_ENVIRONMENT: codercom-preview-docs
46+
47+
- name: Deploy Preview to Vercel
48+
id: preview
49+
run: ./ci/scripts/deploy_vercel.sh
50+
env:
3251
VERCEL_ORG_ID: team_tGkWfhEGGelkkqUUm9nXq17r
3352
VERCEL_PROJECT_ID: QmZRucMRh3GFk1817ZgXjRVuw5fhTspHPHKct3JNQDEPGd
53+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
54+
55+
- name: Update Deployment
56+
# If we don't specify always, it won't run this check if failed.
57+
# This means the deployment would be stuck pending.
58+
if: always()
59+
run: ./ci/scripts/github_deployment.sh update
60+
env:
61+
GITHUB_DEPLOYMENT: ${{ steps.deployment.outputs.id }}
62+
GITHUB_TOKEN: ${{ github.token }}
63+
DEPLOY_STATUS: ${{ steps.preview.outcome }}
64+
DEPLOY_URL: ${{ steps.preview.outputs.url }}
65+
66+
- name: Comment Credentials
67+
uses: marocchino/sticky-pull-request-comment@v2
68+
if: always()
69+
with:
70+
header: codercom-preview-docs
71+
message: |
72+
✨ Coder.com for PR #${{ github.event.number }} deployed! It will be updated on every commit.
73+
74+
* _Host_: ${{ steps.preview.outputs.url }}/docs
75+
* _Last deploy status_: ${{ steps.preview.outcome }}
76+
* _Commit_: ${{ github.sha }}
77+
* _Workflow status_: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

0 commit comments

Comments
 (0)