2
2
name : Deploy Django Application
3
3
4
4
on :
5
- push :
6
- branches :
7
- - main
5
+ workflow_call :
6
+ inputs :
7
+ environment :
8
+ required : true
9
+ type : string
8
10
jobs :
9
- test :
10
- runs-on : ubuntu-latest
11
- steps :
12
- - uses : actions/checkout@v4
13
- - uses : actions/setup-python@v5
14
- with :
15
- python-version : ' 3.11'
16
- - name : Install dependencies
17
- run : pip install -r requirements.txt && pip install -r requirements.test.txt
18
- - name : Test
19
- run : python manage.py test
20
11
deploy :
21
- needs : test
22
12
runs-on : ubuntu-latest
23
- environment : dev
13
+ environment : ${{ inputs.environment }}
24
14
steps :
25
- - name : Checkout repository
26
- uses : actions/checkout@v2
27
- - name : Set up Docker Buildx
28
- uses : docker/setup-buildx-action@v3
29
- - name : Declare image's tag
30
- shell : bash
31
- run : |
32
- echo "sha_short=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
33
- - name : Build
34
- uses : docker/build-push-action@v6
35
- with :
36
- context : .
37
- push : false
38
- tags : qmra:${{ env.sha_short }}
39
- load : true
40
- - name : Save
41
- run : docker save qmra > img.tar
42
- - name : Push
43
- uses : appleboy/scp-action@v0.1.7
44
- with :
45
- host : ${{ secrets.DEPLOY_HOST }}
46
- username : ${{ secrets.DEPLOY_USER }}
47
- key : ${{ secrets.DEPLOY_SERVER_SSH_KEY }}
48
- source : " img.tar"
49
- target : ${{ secrets.DEPLOY_PATH }}
50
15
- name : Deploy
51
16
uses : appleboy/ssh-action@v1.1.0
52
17
with :
57
22
cd ${{ secrets.DEPLOY_PATH }} && git pull
58
23
microk8s ctr image import img.tar && rm img.tar
59
24
cd infra/helm
60
- microk8s helm upgrade qmra ./qmra -n qmra --set app_secret_key.value=${{ secrets.APP_SECRET_KEY }},image.tag=${{ env.sha_short }}
25
+ microk8s helm upgrade -f ${{ inputs.environment }}.values.yaml qmra ./qmra -n qmra --set app_secret_key.value=${{ secrets.APP_SECRET_KEY }},image.tag=${{ env.sha_short }}
0 commit comments