1
- name : Staging Branch Deployment
2
-
1
+ name : Staging cd pipeline
3
2
on :
4
- workflow_run :
5
- workflows : ["CI"]
6
- types :
7
- - completed
3
+ push :
8
4
branches : [staging]
9
5
10
6
jobs :
11
- on-success :
7
+ build-and-deploy :
12
8
runs-on : ubuntu-latest
13
- if : ${{ github.event.workflow_run.conclusion == 'success' }}
14
9
steps :
15
10
- name : Checkout code
16
11
uses : actions/checkout@v3
17
12
18
- - name : Use SSH Action
13
+ - name : Build image
14
+ run : docker build -t anchor-python-bp-staging:latest -f docker/staging/Dockerfile .
15
+
16
+ - name : Save image
17
+ run : docker save anchor-python-bp-staging:latest | gzip > staging.tar.gz
18
+
19
+ - name : Copy image to server
20
+
21
+ with :
22
+ host : ${{ secrets.HOST }}
23
+ username : ${{ secrets.USERNAME }}
24
+ password : ${{ secrets.PASSWORD }}
25
+ source : " staging.tar.gz"
26
+ target : " /home/${{ secrets.USERNAME }}/boilerplate-python/staging_source_code/docker/staging"
27
+
28
+ - name : Deploy image on server
19
29
20
30
with :
21
31
host : ${{ secrets.HOST }}
22
32
username : ${{ secrets.USERNAME }}
23
33
password : ${{ secrets.PASSWORD }}
24
34
script : |
25
- cd python/staging_source_code/
35
+ cd /home/${{ secrets.USERNAME }}/boilerplate- python/staging_source_code/docker/staging
26
36
git pull origin staging
27
- source .venv/bin/activate
28
- pip install -r requirements.txt
29
- alembic upgrade head
30
-
31
- on-failure :
32
- runs-on : ubuntu-latest
33
- if : ${{ github.event.workflow_run.conclusion == 'failure' }}
34
- steps :
35
- - run : echo 'The triggering workflow failed'
37
+ docker load --input staging.tar.gz
38
+ docker compose -f docker-compose.yml up -d
39
+ rm -f staging.tar.gz
0 commit comments