-
-
Notifications
You must be signed in to change notification settings - Fork 4
56 lines (48 loc) · 1.66 KB
/
publish-site.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
name: Deploy website
on:
workflow_run:
# Esto tiene q hacer match con los nombres de los workflows de tests
workflows: ["Lint and Typecheck"]
branches: [main, release]
types:
- completed
jobs:
publish:
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Publish website to Cloudflare Workers
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
env:
ENVIRONMENT: ${{ github.event.workflow_run.head_branch == 'release' && 'production' || github.event.workflow_run.head_branch == 'main' && 'staging' || 'dev' }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
steps:
- name: ⏳ Cloning repo
uses: actions/checkout@v4
with:
show-progress: false
- name: 📦 Download Cached Package Dependencies
uses: actions/cache@v3
env:
cache-name: NPM
with:
path: ~/.npm
key: CACHE-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
- name: ⬢ Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: "npm"
- name: 📥 Install dependencies
run: npm ci --prefer-offline --no-audit --legacy-peer-deps --cache ~/.npm
- name: 📝 Copy .env file
run: cp .env.${{ env.ENVIRONMENT }} .env
- name: Build project
run: BUILD_ENV=${{ env.ENVIRONMENT }} npm run build
- name: Deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
packageManager: npm
command: deploy --env ${{ env.ENVIRONMENT }} --minify