-
Notifications
You must be signed in to change notification settings - Fork 1
70 lines (60 loc) · 2.28 KB
/
test-workflow.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
name: Build and deploy JAR app to Azure Container Instances - hilfling-backend
on:
push:
branches:
- feature/fg-137
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Azure CLI Login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Log in to Azure Container Registry
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.ACR_LOGIN_SERVER }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Build and push Docker image to ACR
run: |
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/hilfling-backend:${{ github.sha }} .
docker push ${{ secrets.ACR_LOGIN_SERVER }}/hilfling-backend:${{ github.sha }}
- name: Delete existing container instances
run: |
for i in 1 2 3; do
az container delete \
--name hilfling-backend${i} \
--resource-group hilfling-backend_group \
--yes || true
done
- name: Deploy new container instances
run: |
for i in 1 2 3; do
az container create \
--name hilfling-backend${i} \
--resource-group hilfling-backend_group \
--registry-username ${{ secrets.ACR_USERNAME }} \
--registry-password ${{ secrets.ACR_PASSWORD }} \
--image ${{ secrets.ACR_LOGIN_SERVER }}/hilfling-backend:${{ github.sha }} \
--cpu 1 --memory 2 \
--environment-variables DATABASE_USERNAME=${{ secrets.HILFLINGDB_USERNAME }} \
DATABASE_URL=${{ secrets.HILFLINGDB_URL_DEV }} \
DATABASE_PASSWORD=${{ secrets.HILFLINGDB_PASSWORD }} \
--ports 8000 \
--dns-name-label hilfling-backend${i}-dns \
--location norwayeast
done
- name: Delete Docker image from ACR
run: |
az acr repository delete \
--name ${{ secrets.ACR_LOGIN_SERVER }} \
--repository hilfling-backend \
--tag ${{ github.sha }} \
--yes