forked from serverless-dns/serverless-dns
-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (96 loc) · 2.97 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
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: "Deployment: dev || live || b1"
required: false
default: "dev"
env:
GIT_REF: ${{ github.event.inputs.git-ref || github.ref }}
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
# 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_CFG: "fly.toml"
FLY_B1_CFG: "fly.tls.toml"
jobs:
deploy:
name: 🚀 Deploy app
runs-on: ubuntu-latest
steps:
- name: 🚚 Checkout
uses: actions/checkout@v2
with:
ref: ${{ env.GIT_REF }}
- 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 == 'live' }}
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: 🚢 Ship
uses: superfly/[email protected]
with:
args: "deploy
--dockerfile node.Dockerfile
--image-label ${{ env.GIT_HEAD }}
--config ${{ env.FLY_TOML }}
--strategy rolling
"
- name: Registry
if: success()
run: |
echo "::notice::Image @ registry.fly.io/<fly-app-name>:${{ env.GIT_HEAD }}"
shell: bash