-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (87 loc) · 3 KB
/
container-on-fly.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Container on Fly.io
on:
workflow_call:
inputs:
staging_app_name:
description: Staging Fly.io app name, optional when already specified in the fly.toml
type: string
required: false
production_app_name:
description: Production Fly.io app name, optional when already specified in the fly.toml
type: string
required: false
staging_branch:
description: Branch used to deploy to staging
type: string
default: main
staging_fly_config_path:
description: Path to the fly config for the staging environment
type: string
default: fly.toml
production_fly_config_path:
description: Path to the fly config for the staging environment
type: string
default: fly.toml
lint_fly_config:
description: If we should lint the fly.toml config.
type: boolean
default: true
secrets:
FLY_API_TOKEN_STAGING:
required: false
FLY_API_TOKEN_PRODUCTION:
required: false
concurrency:
group: ${{ github.workflow_ref }}
cancel-in-progress: false
jobs:
lint-fly-config:
name: Lint Fly config
if: inputs.lint_fly_config
runs-on: ubuntu-latest
steps:
- uses: superfly/flyctl-actions/setup-flyctl@master
- uses: actions/checkout@v4
- run: flyctl config validate --config "${{ inputs.staging_fly_config_path }}"
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_STAGING }}
- run: flyctl config validate --config "${{ inputs.production_fly_config_path }}"
if: inputs.staging_fly_config_path != inputs.production_fly_config_path
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_STAGING }}
build-and-deploy:
name: Fly deploy
needs:
- lint-fly-config
if: |
github.event_name == 'release' ||
(
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch'
) && github.ref_name == inputs.staging_branch
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-fly-deploy-${{ github.ref_name }}
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy to staging
if: github.ref_name == inputs.staging_branch
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_STAGING }}
FLY_APP: ${{ inputs.staging_app_name }}
run: |
flyctl deploy \
--config ${{ inputs.staging_fly_config_path }} \
--remote-only \
--build-arg APP_VERSION="0.0.1-staging-${{ github.sha }}"
- name: Deploy to production
if: github.event_name == 'release'
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_PRODUCTION }}
FLY_APP: ${{ inputs.production_app_name }}
run: |
flyctl deploy \
--config ${{ inputs.production_fly_config_path }} \
--remote-only \
--build-arg APP_VERSION="${{ github.ref_name }}"