forked from serverless-dns/serverless-dns
-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (121 loc) · 3.91 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
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
- mach
- b1
env:
GIT_REF: ${{ github.event.inputs.git-ref || github.ref }}
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
# one of immediate, rolling, bluegreen, canary
FLY_DEPLOY_STRAT: "rolling"
# default fly app to deploy to (typically, dev)
FLY_APP: ${{ secrets.FLY_APP_NAME }}
FLY_PROD_APP: ${{ secrets.FLY_APP_NAME_LIVE }}
FLY_B1_APP: ${{ secrets.FLY_APP_NAME_B1 }}
FLY_MACHINES_APP: "udns"
FLY_CFG: "fly.toml"
FLY_B1_CFG: "fly.tls.toml"
FLY_MACHINES_CFG: "fly.machines.toml"
jobs:
deploy:
name: 🚀 Deploy app
runs-on: ubuntu-latest
steps:
- name: 🚚 Checkout
uses: actions/checkout@v3
with:
ref: ${{ env.GIT_REF }}
fetch-depth: 0
- name: 🏗 Git rev-parse
run: |
echo "GIT_HEAD=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "FLY_TOML=${FLY_CFG}" >> $GITHUB_ENV
shell: bash
- name: 🔐👨🚒 B1 via dispatch?
if: ${{ github.event_name == 'workflow_dispatch' &&
github.event.inputs.deployment-type == 'b1' }}
run: |
echo "FLY_APP=${FLY_B1_APP}" >> $GITHUB_ENV
echo "FLY_TOML=${FLY_B1_CFG}" >> $GITHUB_ENV
echo "::notice::Deploying B1 / ${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: 🚜👨🚒 Machines via dispatch?
if: ${{ github.event_name == 'workflow_dispatch' &&
github.event.inputs.deployment-type == 'mach' }}
run: |
echo "FLY_APP=${FLY_MACHINES_APP}" >> $GITHUB_ENV
echo "FLY_TOML=${FLY_MACHINES_CFG}" >> $GITHUB_ENV
echo "FLY_DEPLOY_STRAT=immediate" >> $GITHUB_ENV
echo "::notice::Deploying MACH / ${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
--image-label ${{ env.GIT_HEAD }}
--config ${{ env.FLY_TOML }}
--strategy ${{ env.FLY_DEPLOY_STRAT }}
--verbose
"
- name: 📕 Registry
if: success()
run: |
echo "::notice::Image @ registry.fly.io/<fly-app-name>:${{ env.GIT_HEAD }}"
shell: bash