-
Notifications
You must be signed in to change notification settings - Fork 119
137 lines (133 loc) · 5.17 KB
/
api.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: API
on:
push:
branches:
- main
paths:
- 'packages/api/**'
- 'packages/db/**'
- '.github/workflows/api.yml'
- 'package-lock.json'
pull_request:
paths:
- 'packages/api/**'
- 'packages/db/**'
- '.github/workflows/api.yml'
- 'package-lock.json'
workflow_dispatch:
inputs:
force_deploy_staging:
description: whether to deploy to staging even if the job wouldn't normally run
required: true
type: boolean
default: false
force_deploy_production:
description: whether to deploy to production even if the job wouldn't normally run
required: true
type: boolean
default: false
jobs:
test:
runs-on: ubuntu-latest
name: Test
steps:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1
- uses: actions/setup-node@v2
with:
node-version: 18
- uses: bahmutov/npm-install@v1
- run: npm run build --workspace packages/api
- run: npm test --workspace packages/api
env:
PG_REST_URL: ${{secrets.PG_REST_URL}}
PG_REST_JWT: ${{secrets.PG_REST_JWT}}
PG_CONNECTION: ${{secrets.PG_CONNECTION}}
changelog:
name: Changelog
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: test
outputs:
releases_created: ${{ steps.tag-release.outputs.releases_created }}
steps:
- uses: GoogleCloudPlatform/release-please-action@v3
id: tag-release
with:
path: packages/api
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
monorepo-tags: true
package-name: api
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Other Changes","hidden":false}]'
deploy-staging:
name: Deploy Staging
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event.inputs.force_deploy_staging
runs-on: ubuntu-latest
needs: test
environment:
name: staging
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 18
- uses: bahmutov/npm-install@v1
- name: Publish api worker
uses: cloudflare/wrangler-action@v3
env:
ENV: 'staging' # inform the build process what the env is
SENTRY_TOKEN: ${{ secrets.SENTRY_TOKEN}}
SENTRY_UPLOAD: ${{ secrets.SENTRY_UPLOAD}}
NEXT_PUBLIC_W3UP_LAUNCH_SUNSET_ANNOUNCEMENT_START: ${{ vars.NEXT_PUBLIC_W3UP_LAUNCH_SUNSET_ANNOUNCEMENT_START }}
NEXT_PUBLIC_W3UP_LAUNCH_SUNSET_START: ${{ vars.NEXT_PUBLIC_W3UP_LAUNCH_SUNSET_START }}
NEXT_PUBLIC_W3UP_LAUNCH_LIMITED_AVAILABILITY_START: ${{ vars.NEXT_PUBLIC_W3UP_LAUNCH_LIMITED_AVAILABILITY_START }}
with:
apiToken: ${{ secrets.CF_TOKEN }}
workingDirectory: 'packages/api'
environment: 'staging'
vars: |
NEXT_PUBLIC_W3UP_LAUNCH_LIMITED_AVAILABILITY_START
NEXT_PUBLIC_W3UP_LAUNCH_SUNSET_ANNOUNCEMENT_START
NEXT_PUBLIC_W3UP_LAUNCH_SUNSET_START
- name: Test upload to staging
# api-staging.web3.storage is now in read-only mode to match api.web3.storage being in 'read only' mode due to product sunset
continue-on-error: true
run: |
npm run build -w packages/client
echo "$(date --utc --iso-8601=seconds) web3.storage upload test" > ./upload-test-small
./packages/w3/bin.js put ./upload-test-small --api https://api-staging.web3.storage --token ${{ secrets.STAGING_WEB3_TOKEN }}
deploy-production:
name: Deploy Production
if: (github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.changelog.outputs.releases_created) || github.event.inputs.force_deploy_production
runs-on: ubuntu-latest
needs:
- test
- changelog
environment:
name: production
url: https://web3.storage
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- uses: bahmutov/npm-install@v1
- name: API - Deploy to Cloudflare
uses: cloudflare/wrangler-action@v3
env:
ENV: 'production' # inform the build process what the env is
SENTRY_TOKEN: ${{ secrets.SENTRY_TOKEN}}
SENTRY_UPLOAD: ${{ secrets.SENTRY_UPLOAD}}
NEXT_PUBLIC_W3UP_LAUNCH_SUNSET_ANNOUNCEMENT_START: ${{ vars.NEXT_PUBLIC_W3UP_LAUNCH_SUNSET_ANNOUNCEMENT_START }}
NEXT_PUBLIC_W3UP_LAUNCH_SUNSET_START: ${{ vars.NEXT_PUBLIC_W3UP_LAUNCH_SUNSET_START }}
NEXT_PUBLIC_W3UP_LAUNCH_LIMITED_AVAILABILITY_START: ${{ vars.NEXT_PUBLIC_W3UP_LAUNCH_LIMITED_AVAILABILITY_START }}
with:
apiToken: ${{ secrets.CF_TOKEN }}
workingDirectory: 'packages/api'
environment: 'production'
vars: |
NEXT_PUBLIC_W3UP_LAUNCH_LIMITED_AVAILABILITY_START
NEXT_PUBLIC_W3UP_LAUNCH_SUNSET_ANNOUNCEMENT_START
NEXT_PUBLIC_W3UP_LAUNCH_SUNSET_START