-
Notifications
You must be signed in to change notification settings - Fork 23
52 lines (51 loc) · 1.57 KB
/
deploy-to-preview.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
name: Deploy Preview
on:
push:
branches:
- main
paths-ignore:
- README.md
- CHANGELOG.md
- MIT-LICENSE
- .env
- doc/**
- bin/**
- .docker/**
- .vscode/**
- .gitignore
jobs:
deploy_preview:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Publish to Cloudflare Pages
timeout-minutes: 10
environment:
name: preview
url: ${{ steps.deploy.outputs.deployment-url }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm install
- name: Build
run: |
response=$(curl -s -o /dev/null -w "%{http_code}" -X GET "https://api.cloudflare.com/client/v4/accounts/${{ secrets.CLOUDFLARE_ACCOUNT_ID }}/pages/projects/favicon" \
-H "Authorization: Bearer ${{ secrets.CLOUDFLARE_API_TOKEN }}")
if [ $response -eq 404 ]; then
echo "Project does not exist, creating..."
npx wrangler pages project create favicon --production-branch main
else
echo "Project exists, skipping creation."
fi
npm run pages:build
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- name: Deploy to Cloudflare Pages
id: deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy --branch dev