Skip to content

Commit 09362c1

Browse files
committed
Cleanup deployment workflow
1 parent a7981a0 commit 09362c1

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

.github/workflows/deploy.yml

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,11 @@ jobs:
123123
build-args: |
124124
PRETIX_IMAGE=${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com/pythonit/pretix:pretix-base-${{ steps.git.outputs.githash }}
125125
126-
build-and-push-arm-service:
126+
build-be:
127127
runs-on: [self-hosted]
128128
permissions:
129129
packages: write
130130
contents: read
131-
strategy:
132-
fail-fast: false
133-
matrix:
134-
service:
135-
- name: pycon-backend
136-
dir: backend
137131

138132
steps:
139133
- uses: actions/checkout@v4
@@ -149,13 +143,13 @@ jobs:
149143
- name: Get service githash
150144
id: git
151145
run: |
152-
hash=$(git rev-list -1 HEAD -- ${{ matrix.service.dir }})
146+
hash=$(git rev-list -1 HEAD -- backend)
153147
echo "githash=$hash" >> $GITHUB_OUTPUT
154148
- name: Check if commit is already on ECR
155149
id: image
156150
run: |
157151
set +e
158-
aws ecr describe-images --repository-name=pythonit/${{ matrix.service.name }} --image-ids=imageTag=arm-${{ steps.git.outputs.githash }}
152+
aws ecr describe-images --repository-name=pythonit/pycon-backend --image-ids=imageTag=arm-${{ steps.git.outputs.githash }}
159153
if [[ $? == 0 ]]; then
160154
echo "image_exists=1" >> $GITHUB_OUTPUT
161155
else
@@ -182,21 +176,21 @@ jobs:
182176
if: ${{ steps.image.outputs.image_exists == 0 }}
183177
uses: docker/build-push-action@v6
184178
with:
185-
context: ./${{ matrix.service.dir }}
186-
file: ./${{ matrix.service.dir }}/Dockerfile
179+
context: ./backend
180+
file: ./backend/Dockerfile
187181
builder: ${{ steps.buildx.outputs.name }}
188182
provenance: false
189183
push: true
190184
tags: |
191-
${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com/pythonit/${{ matrix.service.name }}:arm-${{ steps.git.outputs.githash }}
192-
ghcr.io/pythonitalia/pycon/${{ matrix.service.name }}:arm-${{ steps.git.outputs.githash }}
185+
${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com/pythonit/pycon-backend:arm-${{ steps.git.outputs.githash }}
186+
ghcr.io/pythonitalia/pycon/pycon-backend:arm-${{ steps.git.outputs.githash }}
193187
cache-from: type=local,src=/tmp/.buildx-cache
194188
cache-to: type=local,dest=/tmp/.buildx-cache
195189
platforms: linux/arm64
196190

197-
terraform:
191+
deploy-be:
198192
runs-on: ubuntu-24.04
199-
needs: [build-and-push-arm-service, build-pretix, create-db]
193+
needs: [build-be, build-pretix, create-db]
200194
environment:
201195
name: ${{ fromJSON('["pastaporto", "production"]')[github.ref == 'refs/heads/main'] }}
202196
defaults:
@@ -228,27 +222,21 @@ jobs:
228222
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
229223
AWS_DEFAULT_REGION: eu-central-1
230224

231-
wait-aws-update:
225+
wait-be-update:
232226
runs-on: ubuntu-24.04
233-
needs: [terraform]
227+
needs: [deploy-be]
234228
steps:
235-
- name: Check health status
229+
- name: Wait stable deployment
236230
run: |
237-
while true; do
238-
response=$(curl -s "https://${{ fromJSON('["pastaporto-", ""]')[github.ref == 'refs/heads/main'] }}admin.pycon.it/health")
239-
commit=$(echo $response | jq -r '.commit')
240-
if [ "$commit" == "${{ steps.git.outputs.githash }}" ]; then
241-
echo "New version live"
242-
break
243-
else
244-
echo "Commit hash does not match. Retrying..."
245-
sleep 3
246-
fi
247-
done
231+
aws ecs wait services-stable --cluster pythonit-${{ fromJSON('["pastaporto", "production"]')[github.ref == 'refs/heads/main'] }} --services "backend-web" "backend-worker"
248232
shell: bash
233+
env:
234+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
235+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
236+
AWS_DEFAULT_REGION: eu-central-1
249237

250238
build-fe:
251-
needs: [wait-aws-update]
239+
needs: [wait-be-update]
252240
runs-on: [self-hosted]
253241
permissions:
254242
packages: write
@@ -366,3 +354,16 @@ jobs:
366354
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
367355
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
368356
AWS_DEFAULT_REGION: eu-central-1
357+
358+
wait-fe-update:
359+
runs-on: ubuntu-24.04
360+
needs: [deploy-fe]
361+
steps:
362+
- name: Wait stable deployment
363+
run: |
364+
aws ecs wait services-stable --cluster pythonit-${{ fromJSON('["pastaporto", "production"]')[github.ref == 'refs/heads/main'] }} --services "frontend"
365+
shell: bash
366+
env:
367+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
368+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
369+
AWS_DEFAULT_REGION: eu-central-1

0 commit comments

Comments
 (0)