Skip to content

Commit 6c1671e

Browse files
committed
ci: add build-and-deploy-stg to create staging env for integration & load test
1 parent 5c616a9 commit 6c1671e

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ name: CI
77
jobs:
88
lint:
99
uses: ./.github/workflows/lint.yml
10-
build-and-deploy:
10+
build-and-deploy-stg:
1111
runs-on: ubuntu-latest
12+
needs:
13+
- lint
1214
steps:
1315
- uses: actions/checkout@v3
1416
- uses: actions/setup-node@v3
@@ -20,13 +22,25 @@ jobs:
2022
env:
2123
CI: true
2224
- uses: cloudflare/wrangler-action@1.3.0
23-
name: Deploy to Cloudflare
25+
name: Deploy to Cloudflare (Staging)
2426
with:
2527
apiToken: "${{ secrets.CF_API_TOKEN }}"
28+
environment: "staging"
29+
k6-load-test:
30+
runs-on: ubuntu-latest
31+
timeout-minutes: 30
32+
needs:
33+
- build-and-deploy-stg
34+
steps:
35+
- uses: actions/checkout@v3
36+
- uses: grafana/k6-action@v0.2.0
37+
name: Run k6 local test
38+
with:
39+
filename: scripts/test.js
2640
semantic-release:
2741
runs-on: ubuntu-latest
2842
needs:
29-
- build-and-deploy
43+
- k6-load-test
3044
steps:
3145
- uses: actions/checkout@v3
3246
- uses: actions/setup-node@v3
@@ -35,18 +49,26 @@ jobs:
3549
cache: npm
3650
- run: npm ci
3751
- run: npx semantic-release
38-
name: Semantic Release
52+
name: Run Semantic Release
3953
env:
4054
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
4155
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
42-
load-test:
56+
build-and-deploy-prd:
4357
runs-on: ubuntu-latest
44-
timeout-minutes: 30
4558
needs:
46-
- build-and-deploy
59+
- k6-load-test
4760
steps:
4861
- uses: actions/checkout@v3
49-
- uses: grafana/k6-action@v0.2.0
50-
name: Run k6 test
62+
- uses: actions/setup-node@v3
5163
with:
52-
filename: scripts/test.js
64+
node-version: lts/*
65+
cache: npm
66+
- run: npm ci
67+
- run: npm run build --if-present
68+
env:
69+
CI: true
70+
- uses: cloudflare/wrangler-action@1.3.0
71+
name: Deploy to Cloudflare (Production)
72+
with:
73+
apiToken: "${{ secrets.CF_API_TOKEN }}"
74+
environment: "production"

scripts/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const options = {
1212

1313
let shortenLink
1414

15-
const BASE_URL = 'https://s.jerrynsh.com'
15+
const BASE_URL = 'https://atomic-url-staging.jerrynsh.workers.dev/'
1616
const DUMMY_ORIGINAL_URL = 'https://jerrynsh.com/i-built-my-own-tiny-url/'
1717

1818
export default function () {

0 commit comments

Comments
 (0)