-
Notifications
You must be signed in to change notification settings - Fork 18
65 lines (57 loc) · 1.94 KB
/
deploy-backend.yml
File metadata and controls
65 lines (57 loc) · 1.94 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
56
57
58
59
60
61
62
63
64
65
name: Deploy Backend to Heroku
on:
push:
branches: [main]
paths:
- "backend/**"
- ".github/workflows/deploy-backend.yml"
jobs:
deploy-backend:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect backend changes
id: changes
uses: dorny/paths-filter@v3
with:
token: ${{ github.token }}
filters: |
backend:
- 'backend/Dockerfile'
- 'backend/Cargo.toml'
- 'backend/Cargo.lock'
- 'backend/src/**'
- 'backend/migrations/**'
- 'backend/rustfmt.toml'
- name: Install Heroku CLI
run: |
curl https://cli-assets.heroku.com/install.sh | sh
if: steps.changes.outputs.backend == 'true'
- name: Heroku Container Registry login
env:
HEROKU_EMAIL: ${{ secrets.HEROKU_EMAIL }}
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: |
echo "$HEROKU_API_KEY" | docker login -u "$HEROKU_EMAIL" --password-stdin registry.heroku.com
if: steps.changes.outputs.backend == 'true'
- name: Build and push (linux/amd64)
env:
HEROKU_BACKEND_APP: ${{ secrets.HEROKU_BACKEND_APP }}
run: |
DOCKER_BUILDKIT=0 docker build \
--platform linux/amd64 \
--target production \
-t registry.heroku.com/${HEROKU_BACKEND_APP}/web \
-f backend/Dockerfile backend
docker push registry.heroku.com/${HEROKU_BACKEND_APP}/web
if: steps.changes.outputs.backend == 'true'
- name: Release on Heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
HEROKU_BACKEND_APP: ${{ secrets.HEROKU_BACKEND_APP }}
run: |
heroku container:release web -a "${HEROKU_BACKEND_APP}"
if: steps.changes.outputs.backend == 'true'