-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (135 loc) · 4.89 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
163
164
165
166
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
GH_IMAGE: sierrasoftworks/bender
VERSION: dev
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-latest
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- 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
if: github.event_name == 'push'
run: |
IMAGE_ID=$(echo '${{ github.repository }}/${{ github.event.repository.name }}' | tr '[:upper:]' '[:lower:]')
echo "GH_IMAGE=$IMAGE_ID" >> $GITHUB_ENV
VERSION=$(git describe --tags 2>/dev/null || git rev-parse --short HEAD)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Calculate version number
id: repo
run: |
IMA=$(git describe --tags 2>/dev/null || git rev-parse --short HEAD)
echo "::set-output name=version::$VERSION"
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
labels: org.opencontainers.image.authors=SierraSoftworks,org.opencontainers.image.version=${{ env.VERSION }},org.opencontainers.image.revision=${{ github.sha }}
tags: ${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ env.VERSION }},docker.pkg.github.com/${{ env.GH_IMAGE }}:latest,docker.pkg.github.com/${{ env.GH_IMAGE }}:${{ env.VERSION }}
- run: |
docker run --rm -t -v $PWD:/volume ${{ env.IMAGE }}:${{ env.VERSION }} cp /app/$HANDLER_NAME /volume/handler
mv ./handler ./$HANDLER_NAME
- name: Save handler artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.HANDLER_NAME }}
path: ${{ env.HANDLER_NAME }}
deploy-staging:
needs: build
runs-on: ubuntu-latest
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@v4
with:
name: ${{ env.HANDLER_NAME }}
- name: 'Login via Azure CLI'
uses: Azure/login@v2
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-latest
steps:
- name: Probe
uses: Jtalk/url-health-check-action@v4
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-latest
steps:
- uses: actions/checkout@v4
- name: Fetch handler artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.HANDLER_NAME }}
- name: 'Login via Azure CLI'
uses: azure/login@v2
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-latest
steps:
- name: Probe
uses: Jtalk/url-health-check-action@v4
with:
url: ${{ env.LIVE_HEALTHCHECK }}
max-attempts: 5
retry-delay: 10s
follow-redirect: true