-
Notifications
You must be signed in to change notification settings - Fork 1
105 lines (88 loc) · 3.01 KB
/
main.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
name: ACMI Collection Chat CI
on: [push]
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_REPOSITORY: acmilabs/collection-chat
DOCKER_IMAGE_TAG: ${{ github.sha }}
AZURE_WEBAPP_NAME: "collection-chat-appservice"
jobs:
build-chat:
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- name: Build standard image (cached)
if: success()
uses: whoan/docker-build-with-cache-action@v4
with:
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
image_name: "${{ env.DOCKER_REPOSITORY }}"
image_tag: "${{ env.DOCKER_IMAGE_TAG }}"
build_extra_args: "--compress=true"
push_git_tag: true
- name: cancel entire action if failed
if: failure()
uses: andymckay/[email protected]
build-and-test-python:
needs: [build-chat]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build Python lint and test
run: |
cp config.tmpl.env config.env
cd development && docker-compose -f docker-compose.yml up --build -d
- name: Run Python lint and test
run: docker exec chat make linttest
- name: cancel entire action if failed
if: failure()
uses: andymckay/[email protected]
build-chat-latest:
if: github.ref == 'refs/heads/main'
needs: [build-and-test-python]
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- name: Build the latest image for production (cached)
if: success()
uses: whoan/docker-build-with-cache-action@v5
with:
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
image_name: "${{ env.DOCKER_REPOSITORY }}"
image_tag: "latest"
build_extra_args: "--compress=true"
push_git_tag: true
- name: cancel entire action if failed
if: failure()
uses: andymckay/[email protected]
deploy:
needs: [build-and-test-python, build-chat-latest]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Azure authentication
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: ACR authentication
uses: azure/docker-login@v1
with:
login-server: ${{ env.DOCKER_REPOSITORY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: 'Deploy to Azure Web App for Container'
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
images: ${{ env.DOCKER_REPOSITORY }}:latest