Albert Pai commited on
Commit
4919627
·
unverified ·
1 Parent(s): 58af0de

ci: deploy to cloudflare (#19)

Browse files
.github/actions/setup-and-build/action.yaml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Setup and Build
2
+ description: Generic setup action
3
+ inputs:
4
+ pnpm-version:
5
+ required: false
6
+ type: string
7
+ default: '9.4.0'
8
+ node-version:
9
+ required: false
10
+ type: string
11
+ default: '20.15.1'
12
+
13
+ runs:
14
+ using: composite
15
+
16
+ steps:
17
+ - uses: pnpm/action-setup@v4
18
+ with:
19
+ version: ${{ inputs.pnpm-version }}
20
+ run_install: false
21
+
22
+ - name: Set Node.js version to ${{ inputs.node-version }}
23
+ uses: actions/setup-node@v4
24
+ with:
25
+ node-version: ${{ inputs.node-version }}
26
+ cache: pnpm
27
+
28
+ - name: Install dependencies and build project
29
+ shell: bash
30
+ run: |
31
+ pnpm install
32
+ pnpm run build
.github/workflows/ci.yaml CHANGED
@@ -1,4 +1,4 @@
1
- name: CI
2
 
3
  on:
4
  push:
@@ -14,17 +14,8 @@ jobs:
14
  - name: Checkout
15
  uses: actions/checkout@v4
16
 
17
- - uses: actions/setup-node@v4
18
- with:
19
- node-version: '20.15.1'
20
-
21
- - uses: pnpm/action-setup@v4
22
- with:
23
- version: 9.4.0
24
- run_install: false
25
-
26
- - name: Install dependencies
27
- run: pnpm install
28
 
29
  - name: Run type check
30
  run: pnpm run typecheck
@@ -34,3 +25,54 @@ jobs:
34
 
35
  - name: Run tests
36
  run: pnpm run test
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: CI/CD
2
 
3
  on:
4
  push:
 
14
  - name: Checkout
15
  uses: actions/checkout@v4
16
 
17
+ - name: Setup and Build
18
+ uses: ./.github/actions/setup-and-build
 
 
 
 
 
 
 
 
 
19
 
20
  - name: Run type check
21
  run: pnpm run typecheck
 
25
 
26
  - name: Run tests
27
  run: pnpm run test
28
+
29
+ build-and-deploy:
30
+ name: Build and Deploy
31
+ needs: test
32
+ runs-on: ubuntu-latest
33
+ environment: ${{ github.ref_name == 'master' && 'production' || 'staging' }}
34
+ if: ${{ github.ref != 'refs/heads/master' }}
35
+ steps:
36
+ - name: Checkout
37
+ uses: actions/checkout@v4
38
+
39
+ - name: Setup and Build
40
+ uses: ./.github/actions/setup-and-build
41
+
42
+ - name: Deploy to Cloudflare
43
+ id: deploy
44
+ uses: cloudflare/wrangler-action@v3
45
+ with:
46
+ wranglerVersion: '* -w'
47
+ packageManager: pnpm
48
+ workingDirectory: 'packages/bolt'
49
+ apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
50
+ accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
51
+ command: pages deploy
52
+
53
+ - name: Deployment URL
54
+ env:
55
+ DEPLOYMENT_URL: ${{ steps.deploy.outputs.deployment-url }}
56
+ run: echo $DEPLOYMENT_URL
57
+
58
+ - name: Comment on Commit
59
+ if: github.event_name == 'push'
60
+ uses: hasura/[email protected]
61
+ with:
62
+ github-token: ${{ secrets.GITHUB_TOKEN }}
63
+ repository: ${{ github.repository }}
64
+ id: deploy-preview-commit
65
+ commit-sha: ${{ github.sha }}
66
+ message: '${{ github.sha }} has been deployed to ${{ steps.deploy.outputs.deployment-url }} :rocket:'
67
+ recreate: true
68
+
69
+ - name: Comment on PR
70
+ if: github.event_name == 'pull_request'
71
+ uses: hasura/[email protected]
72
+ with:
73
+ github-token: ${{ secrets.GITHUB_TOKEN }}
74
+ repository: ${{ github.repository }}
75
+ id: deploy-preview-pr
76
+ number: ${{ github.event.number }}
77
+ message: '#${{ github.event.number }} has been deployed to ${{ steps.deploy.outputs.deployment-url }} :rocket:'
78
+ recreate: true
package.json CHANGED
@@ -5,6 +5,7 @@
5
  "scripts": {
6
  "playground:dev": "pnpm run --filter=playground dev",
7
  "lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
 
8
  "test": "pnpm run -r test",
9
  "typecheck": "pnpm run -r typecheck"
10
  },
 
5
  "scripts": {
6
  "playground:dev": "pnpm run --filter=playground dev",
7
  "lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
8
+ "build": "pnpm run -r build",
9
  "test": "pnpm run -r test",
10
  "typecheck": "pnpm run -r typecheck"
11
  },