-
Notifications
You must be signed in to change notification settings - Fork 6
58 lines (48 loc) · 1.91 KB
/
Copy pathcd.yml
File metadata and controls
58 lines (48 loc) · 1.91 KB
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
name: "Continuous Deployment"
env:
AZURE_WEBAPP_NAME: 'mysql-copilot-api'
PYTHON_VERSION: '3.12'
on:
workflow_dispatch:
inputs:
approve_deploy:
description: "Approve deployment"
required: true
type: boolean
permissions:
contents: read
jobs:
cd:
runs-on: ubuntu-latest
if: github.event.inputs.approve_deploy == true
steps:
- uses: actions/checkout@v4
- name: Set up Python version
uses: actions/setup-python@v3.0.0
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Azure login using service principal
uses: azure/login@a65d910e8af852a8061c627c456678983e180302 #v2.2.0
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Azure docker login
uses: azure/docker-login@15c4aadf093404726ab2ff205b2cdd33fa6d054c #v2
with:
login-server: ${{ secrets.REGISTRY_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Docker build and push
run: |
docker build . -t ${{ secrets.REGISTRY_SERVER }}/${{ env.AZURE_WEBAPP_NAME }}:${{ github.sha }}
docker tag ${{ secrets.REGISTRY_SERVER }}/${{ env.AZURE_WEBAPP_NAME }}:${{ github.sha }} ${{ secrets.REGISTRY_SERVER }}/${{ env.AZURE_WEBAPP_NAME }}:latest
docker push ${{ secrets.REGISTRY_SERVER }}/${{ env.AZURE_WEBAPP_NAME }}:${{ github.sha }}
docker push ${{ secrets.REGISTRY_SERVER }}/${{ env.AZURE_WEBAPP_NAME }}:latest
- name: Azure WebApp deploy
uses: azure/webapps-deploy@de617f46172a906d0617bb0e50d81e9e3aec24c8 #v3.0.1
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
images: ${{ secrets.REGISTRY_SERVER }}/${{ env.AZURE_WEBAPP_NAME }}:${{ github.sha }}