-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (59 loc) · 1.96 KB
/
build.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
name: cloudflare
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
if: contains(github.event.head_commit.message, '[skip ci]') == false
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v3
- name: 📸 Calculate commit hash
id: sha
uses: pr-mpt/actions-commit-hash@v2
- name: 🔨 Prepare Node environment
uses: actions/setup-node@v4
with:
node-version: 22
- name: 🎉 Install project dependencies
run: yarn install
- name: 🏗️ Build app
run: yarn run build
env:
VITE_CLIENT_ID: ${{ secrets.CLIENT_ID }}
VITE_REDIRECT_URI: ${{ secrets.REDIRECT_URI }}
- name: 🚀 Deploy to Cloudflare Pages
id: cloudflare_pages_deploy
uses: cloudflare/wrangler-action@2.0.0
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: "pages deploy ./dist --project-name esachievement"
secrets: |
CLIENT_ID
SECRET_CLIENT_ID
REDIRECT_URI
env:
NODE_VERSION: 22
CLIENT_ID: ${{ secrets.CLIENT_ID }}
SECRET_CLIENT_ID: ${{ secrets.SECRET_CLIENT_ID }}
REDIRECT_URI: ${{ secrets.REDIRECT_URI }}
- name: 🚀 Deploy pages based on commit sha
uses: actions/github-script@v6
with:
script: |
const sha = context.payload.pull_request?.head.sha ?? context.sha;
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
context: "cloudflare / build (push)",
description: "Commit based deploy",
state: "success",
sha,
target_url: "esachievement.pages.dev",
});