-
Notifications
You must be signed in to change notification settings - Fork 2
55 lines (47 loc) · 1.85 KB
/
Copy pathdeploy.yml
File metadata and controls
55 lines (47 loc) · 1.85 KB
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
name: Deploy Frontend to Heroku
on:
push:
branches:
- develop
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to Heroku Container Registry
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: |
echo ${{ secrets.HEROKU_API_KEY }} | docker login --username=_ --password-stdin registry.heroku.com
- name: Build and Push Docker Image
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
VITE_API_URL: https://api.deiden.com
run: |
docker build \
--build-arg VITE_API_URL=$VITE_API_URL \
-t registry.heroku.com/deiden-fe/web .
docker push registry.heroku.com/deiden-fe/web
- name: Release to Heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: |
curl https://cli-assets.heroku.com/install.sh | sh
heroku container:release web -a deiden-fe
- name: Purge Cloudflare cache
env:
CF_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: |
# The edge caches www.deiden.com for hours so the dyno can fall asleep, which
# also means a fresh deploy stays invisible until the cache expires.
# Purging here keeps the long TTL without the stale-deploy side effect.
if [ -z "$CF_TOKEN" ]; then
echo "CLOUDFLARE_API_TOKEN is not set - skipping cache purge"
exit 0
fi
curl -sf -X POST "https://api.cloudflare.com/client/v4/zones/4e73769adc63c8c2c055cd8f960f6c60/purge_cache" \
-H "Authorization: Bearer $CF_TOKEN" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}' > /dev/null
echo "purged Cloudflare cache for www.deiden.com"