-
Notifications
You must be signed in to change notification settings - Fork 0
162 lines (135 loc) · 4.74 KB
/
release.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
name: Deploy
on:
push:
branches: [ main ]
paths-ignore:
- "docs/**"
pull_request:
branches: [ main ]
permissions:
id-token: write
packages: write
env:
CARGO_TERM_COLOR: always
HANDLER_NAME: bender
IMAGE: sierrasoftworks/bender
STAGING_DEPLOYMENT_APP_ID: 65d7542d-354d-4129-898c-8848be8d5ecd
STAGING_FUNCTION_NAME: bender-sierrasoftworks-staging
STAGING_HEALTHCHECK: "https://bender-staging.sierrasoftworks.com/api/v1/health"
LIVE_DEPLOYMENT_APP_ID: 5d3fdb10-30ca-4aaa-9128-17101a1ac349
LIVE_FUNCTION_NAME: bender-sierrasoftworks
LIVE_HEALTHCHECK: "https://bender.sierrasoftworks.com/api/v1/health"
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Build Dockerfile
run: docker build . --file Dockerfile --tag image
- run: |
docker run --rm -t -v $PWD:/volume image cp /app/$HANDLER_NAME /volume/handler
mv ./handler ./$HANDLER_NAME
- name: Save handler artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.HANDLER_NAME }}
path: ${{ env.HANDLER_NAME }}
- name: Log into registries
if: github.event_name == 'push'
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
echo "${{ secrets.DOCKER_HUB }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
- name: Calculate version number
id: version
if: github.event_name == 'push'
run: |
VERSION=$(git describe --tags 2>/dev/null || git rev-parse --short HEAD)
echo "::set-output name=version::$VERSION"
- name: Push image to GitHub
if: github.event_name == 'push'
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/${{ github.event.repository.name }}
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
docker tag image $IMAGE_ID:latest
docker push $IMAGE_ID:latest
docker tag image $IMAGE_ID:${{ steps.version.outputs.version }}
docker push $IMAGE_ID:${{ steps.version.outputs.version }}
- name: Push image to Docker Hub
if: github.event_name == 'push'
run: |
IMAGE_ID=${{ env.IMAGE }}
echo IMAGE_ID=$IMAGE_ID
docker tag image $IMAGE_ID:latest
docker push $IMAGE_ID:latest
docker tag image $IMAGE_ID:${{ steps.version.outputs.version }}
docker push $IMAGE_ID:${{ steps.version.outputs.version }}
deploy-staging:
needs: build
runs-on: ubuntu-20.04
if: github.actor != 'dependabot[bot]'
environment:
name: Staging
url: ${{ env.STAGING_HEALTHCHECK }}
steps:
- uses: actions/checkout@v4
- name: Fetch handler artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.HANDLER_NAME }}
- name: 'Login via Azure CLI'
uses: Azure/login@v1
with:
tenant-id: a26571f1-22b3-4756-ac7b-39ca684fab48
subscription-id: 108b3ddb-53fb-4344-80b2-d6c151912be6
client-id: ${{ env.STAGING_DEPLOYMENT_APP_ID }}
- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
with:
app-name: ${{ env.STAGING_FUNCTION_NAME }}
respect-funcignore: 'true'
healthcheck-staging:
needs: deploy-staging
runs-on: ubuntu-20.04
steps:
- name: Probe
uses: Jtalk/url-health-check-action@v3
with:
url: ${{ env.STAGING_HEALTHCHECK }}
max-attempts: 5
retry-delay: 10s
follow-redirect: true
deploy-live:
needs: healthcheck-staging
if: github.event_name == 'push'
environment:
name: Production
url: ${{ env.LIVE_HEALTHCHECK }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Fetch handler artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.HANDLER_NAME }}
- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
tenant-id: a26571f1-22b3-4756-ac7b-39ca684fab48
subscription-id: 108b3ddb-53fb-4344-80b2-d6c151912be6
client-id: ${{ env.LIVE_DEPLOYMENT_APP_ID }}
- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
with:
app-name: ${{ env.LIVE_FUNCTION_NAME }}
respect-funcignore: 'true'
healthcheck-live:
needs: deploy-live
runs-on: ubuntu-20.04
steps:
- name: Probe
uses: Jtalk/url-health-check-action@v3
with:
url: ${{ env.LIVE_HEALTHCHECK }}
max-attempts: 5
retry-delay: 10s
follow-redirect: true