generated from ubiquity/ts-template
-
Notifications
You must be signed in to change notification settings - Fork 29
51 lines (43 loc) · 1.37 KB
/
cloudflare-deploy.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
name: Deploy to Cloudflare Pages
on:
workflow_run:
workflows: ["Conventional Commits"]
types:
- completed
jobs:
deploy-to-cloudflare:
name: Deploy to Cloudflare Pages
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "20.10.0"
- name: Yarn Install
run: yarn install
- name: Build the project
run: yarn build
- name: Wrangler Install
run: yarn add wrangler
- name: Publish to Cloudflare
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
REPOSITORY: ${{ github.repository }}
PRODUCTION_BRANCH: "development"
OUTPUT_DIRECTORY: "static"
run: |
IFS='/' read -ra fields <<< "$REPOSITORY"
projectName="${fields[1]}"
echo $projectName
yarn wrangler pages project list > project_list.txt
if grep -q $projectName project_list.txt; then
echo "Project found"
else
echo "Project not found"
yarn wrangler pages project create "$projectName" --production-branch "$PRODUCTION_BRANCH"
fi
yarn wrangler pages publish "$OUTPUT_DIRECTORY" --project-name "$projectName"