forked from serverless-dns/serverless-dns
-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (145 loc) · 4.6 KB
/
fly.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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: 🪂 Fly
on:
push:
branches:
- "main"
tags:
- "v*"
paths-ignore:
- ".github/**"
- "!.github/workflows/fly.yml"
- ".env.example"
- ".eslintrc.cjs"
- ".prettierignore"
- "wrangler.toml"
- "README.md"
- "wrangler.toml"
- ".vscode/*"
- ".husky/*"
- ".prettierrc.json"
- "LICENSE"
- "run"
workflow_dispatch:
inputs:
git-ref:
description: "Branch / ref / tag to build"
required: false
default: "main"
deployment-type:
description: "Fly app type to deploy to"
required: true
default: 'dev'
type: choice
options:
- dev
- prod
- onebox
- flytls
deployment-strat:
description: "Deploy strategy"
required: true
default: 'rolling'
type: choice
options:
- rolling
- immediate
- bluegreen
- canary
builder:
description: "App builder type"
required: true
default: 'remote-only'
type: choice
options:
- remote-only
- local-only
env:
GIT_REF: ${{ github.event.inputs.git-ref || github.ref }}
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
# one of immediate, rolling (default), bluegreen, canary
FLY_DEPLOY_STRAT: ${{ github.event.inputs.deployment-strat }}
# local-only, remote-only (default)
FLY_BUILDER_TYPE: ${{ github.event.inputs.builder }}
# default fly app to deploy to (typically, dev)
FLY_APP: "rdns-dev"
FLY_TLS_APP: "rdns-b1"
FLY_PROD_ONEBOX_APP: "rdns"
FLY_PROD_APP: "udns"
FLY_CFG: "fly.toml"
FLY_TLS_CFG: "fly.tls.toml"
FLY_DEPLOY_WAIT_SEC: "300"
jobs:
deploy:
name: 🚀 Deploy app
runs-on: ubuntu-latest
steps:
- name: 🚚 Checkout
uses: actions/[email protected]
with:
ref: ${{ env.GIT_REF }}
fetch-depth: 0
- name: 🏗 Setup env vars
run: |
echo "GIT_HEAD=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "FLY_TOML=${FLY_CFG}" >> $GITHUB_ENV
echo "FLY_DEPLOY_STRAT=${FLY_DEPLOY_STRAT:-rolling}" >> $GITHUB_ENV
echo "FLY_BUILDER_TYPE=${FLY_BUILDER_TYPE:-remote-only}" >> $GITHUB_ENV
shell: bash
- name: 🔐👨🚒 FlyTLS via dispatch?
if: ${{ github.event_name == 'workflow_dispatch' &&
github.event.inputs.deployment-type == 'flytls' }}
run: |
echo "FLY_APP=${FLY_TLS_APP}" >> $GITHUB_ENV
echo "FLY_TOML=${FLY_TLS_CFG}" >> $GITHUB_ENV
echo "::notice::Deploying FLYTLS / ${GIT_REF} @ ${COMMIT_SHA}"
shell: bash
env:
COMMIT_SHA: ${{ github.sha }}
- name: 🚨👨🚒 Prod via dispatch?
if: ${{ github.event_name == 'workflow_dispatch' &&
github.event.inputs.deployment-type == 'prod' }}
run: |
echo "FLY_APP=${FLY_PROD_APP}" >> $GITHUB_ENV
echo "::notice::Deploying PROD / ${GIT_REF} @ ${COMMIT_SHA}"
shell: bash
env:
COMMIT_SHA: ${{ github.sha }}
- name: 🚨🛺 Prod via tag?
# docs.github.com/en/actions/learn-github-actions/contexts#github-context
if: ${{ github.event_name != 'workflow_dispatch' && github.ref_type == 'tag' }}
run: |
echo "FLY_APP=${FLY_PROD_APP}" >> $GITHUB_ENV
echo "::notice::Deploying PROD / ${GIT_REF} @ ${COMMIT_SHA}"
shell: bash
env:
COMMIT_SHA: ${{ github.sha }}
- name: 🚜👨🚒 Onebox via dispatch?
if: ${{ github.event_name == 'workflow_dispatch' &&
github.event.inputs.deployment-type == 'onebox' }}
run: |
echo "FLY_APP=${FLY_PROD_ONEBOX_APP}" >> $GITHUB_ENV
echo "::notice::Deploying 1BOX / ${GIT_REF} @ ${COMMIT_SHA}"
shell: bash
env:
COMMIT_SHA: ${{ github.sha }}
# experimental: github.com/superfly/flyctl-actions/pull/20
- name: 🏗 Setup flyctl @ latest
uses: superfly/flyctl-actions/setup-flyctl@master
with:
version: latest
- name: 🚢 Ship
run: "flyctl deploy
--${{ env.FLY_BUILDER_TYPE }}
--image-label ${{ env.GIT_HEAD }}
--config ${{ env.FLY_TOML }}
--strategy ${{ env.FLY_DEPLOY_STRAT }}
--wait-timeout ${{ env.FLY_DEPLOY_WAIT_SEC }}
--auto-confirm
--no-cache
--verbose
"
- name: 📕 Registry
if: success()
run: |
echo "::notice::Image @ registry.fly.io/${{ env.FLY_APP }}:${{ env.GIT_HEAD }}"
shell: bash