-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (71 loc) · 2.36 KB
/
deploy.yaml
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Deploy
on:
- push
jobs:
image:
name: Image
runs-on: ubuntu-22.04
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('**/go.sum') }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-buildx-${{ hashFiles('**/go.sum') }}-
${{ runner.os }}-buildx-
- uses: google-github-actions/auth@v1
id: gcp
with:
token_format: access_token
workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }}
access_token_lifetime: 150s
- uses: docker/login-action@v2
with:
registry: us-central1-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.gcp.outputs.access_token }}
- uses: docker/metadata-action@v4
id: meta
with:
images: us-central1-docker.pkg.dev/wafflehacks-production/internal/mailer
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
publish:
name: Publish
runs-on: ubuntu-22.04
needs: [image]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Replace commit SHA
run: |
short_sha=$(git rev-parse --short HEAD)
sed -i s/SHORT_SHA/$short_sha/g fly.toml
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_TOKEN }}