generated from wabarc/project-template
-
Notifications
You must be signed in to change notification settings - Fork 4
182 lines (157 loc) · 5.44 KB
/
deploy.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Deploy
on:
workflow_dispatch:
inputs:
tier:
description: 'Deployment environment: main, edge'
required: false
default: 'main'
repository_dispatch:
types: [deploy]
jobs:
continue:
name: Continue
runs-on: ubuntu-latest
if: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.from == 'wabarc/wayback' }} || ${{ github.event_name == 'workflow_dispatch' }}
outputs:
tier: ${{ steps.tier.outputs.name }}
steps:
- name: Continue
run: |
echo 'Deploy continue'
- name: Choose environment
id: tier
run: |
if [ -z "${{ github.event.inputs.tier }}" ]; then
echo "::set-output name=name::main"
echo 'Deploy with tier main'
else
echo "::set-output name=name::${{ github.event.inputs.tier }}"
echo 'Deploy with tier ${{ github.event.inputs.tier }}'
fi
demo-x:
name: Deploy Heroku X
runs-on: ubuntu-latest
needs: continue
if: ${{ github.event.client_payload.channel == 'stable' || github.event_name == 'workflow_dispatch' }}
env:
HEROKU_APPNAME: ${{ secrets.HEROKU_APPNAME_X }}
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY_X }}
steps:
- name: Check out code base
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ needs.continue.outputs.tier }}
- name: Set up Heroku
run: |
curl https://cli-assets.heroku.com/install.sh | sh
- name: Set up Heroku repository
run: |
#git remote add heroku "https://${HEROKU_USERNAME}:${HEROKU_API_KEY}@git.heroku.com/${HEROKU_APPNAME}.git"
git remote add heroku "[email protected]:${HEROKU_APPNAME}.git"
- name: Login to the registry
run: |
# docker login --username=_ --password=$(heroku auth:token) registry.heroku.com
heroku container:login
- name: Deploy images
run: |
# docker push registry.heroku.com/<app>/<process-type>
heroku container:push web
- name: Release container
run: |
heroku container:release --app=${HEROKU_APPNAME} web
- name: Scale dynos
run: |
heroku ps:scale web=1
heroku ps
demo-k:
name: Deploy Heroku K
runs-on: ubuntu-latest
needs: continue
if: ${{ github.event.client_payload.channel == 'stable' || github.event_name == 'workflow_dispatch' }}
env:
HEROKU_APPNAME: ${{ secrets.HEROKU_APPNAME_K }}
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY_K }}
steps:
- name: Check out code base
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ needs.continue.outputs.tier }}
- name: Set up Heroku
run: |
curl https://cli-assets.heroku.com/install.sh | sh
- name: Set up Heroku repository
run: |
#git remote add heroku "https://${HEROKU_USERNAME}:${HEROKU_API_KEY}@git.heroku.com/${HEROKU_APPNAME}.git"
git remote add heroku "[email protected]:${HEROKU_APPNAME}.git"
- name: Login to the registry
run: |
# docker login --username=_ --password=$(heroku auth:token) registry.heroku.com
heroku container:login
- name: Deploy images
run: |
# docker push registry.heroku.com/<app>/<process-type>
heroku container:push web
- name: Release container
run: |
heroku container:release --app=${HEROKU_APPNAME} web
- name: Scale dynos
run: |
heroku ps:scale web=1
heroku ps
demo-testing:
name: Deploy Heroku T
runs-on: ubuntu-latest
needs: continue
env:
HEROKU_APPNAME: ${{ secrets.HEROKU_APPNAME_T }}
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY_T }}
steps:
- name: Check out code base
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ needs.continue.outputs.tier }}
- name: Replace base image
run: |
echo 'original:'
head -n1 ./Dockerfile
sed -Ei 's/ghcr.io\/wabarc\/wayback.*/ghcr.io\/wabarc\/wayback:edge/g' ./Dockerfile
echo 'replaced:'
head -n1 ./Dockerfile
- name: Set up Heroku
run: |
curl https://cli-assets.heroku.com/install.sh | sh
- name: Set up Heroku repository
run: |
#git remote add heroku "https://${HEROKU_USERNAME}:${HEROKU_API_KEY}@git.heroku.com/${HEROKU_APPNAME}.git"
git remote add heroku "[email protected]:${HEROKU_APPNAME}.git"
- name: Login to the registry
run: |
# docker login --username=_ --password=$(heroku auth:token) registry.heroku.com
heroku container:login
- name: Deploy images
run: |
# docker push registry.heroku.com/<app>/<process-type>
heroku container:push web
- name: Release container
run: |
heroku container:release --app=${HEROKU_APPNAME} web
- name: Scale dynos
run: |
heroku ps:scale web=1
heroku ps
dispatch:
name: Repository Dispatch
runs-on: ubuntu-latest
needs: [demo-x, demo-k]
steps:
- name: Dispatch repository in wabarc/on-heroku
uses: peter-evans/repository-dispatch@v2
with:
repository: wabarc/heroku-schedule
event-type: release
token: ${{ secrets.PAT_WORKFLOW }}
client-payload: '{"from": "${{ github.repository }}"}'