-
Notifications
You must be signed in to change notification settings - Fork 20
57 lines (51 loc) · 1.93 KB
/
deploy_release.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
name: Deploy-to-production
on:
release:
types: [published]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
get-versiontag-n-update-code:
runs-on: ubuntu-latest
steps:
# Checkout the branch
- name: checkout
uses: actions/checkout@v3
- name: change the version in main.py
run: |
VERSION=$(echo $GITHUB_REF | sed 's|.*/v||')
echo ${VERSION}
sed -i "s|version=\".*\",|version=\"${VERSION}\",|" app/main.py
head -n 33 app/main.py | tail -n 4
- name: Commit changes
run: |
git config --global user.name "${{ secrets.CICD_BOT_USER }}"
git config --global user.email "${{ secrets.CICD_BOT_EMAIL }}"
git config --global user.password "${{ secrets.CICD_BOT_PASS }}"
git add ./app/main.py
git commit -m 'Bump version automatically on release'
git tag -a $(git describe --tags --abbrev=0) -m "moving tag to new commit" -f $(git rev-parse HEAD)
git push -f origin refs/tags/$(git describe --tags --abbrev=0)
- name: Pushing to the protected branch 'version-2'
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.CICD_BOT_PAT }}
branch: version-2
tags: true
unprotect_reviews: true
pull-n-deploy:
needs: get-versiontag-n-update-code
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VACHAN_DO_HOST_PROD }}
username: ${{ secrets.VACHAN_DO_USERNAME_PROD }}
key: ${{ secrets.SSH_KEY_PROD }}
port: 22
script: |
cd /home/vachanstaging/vachan-api
git pull origin version-2
cd docker
docker compose -f docker-compose-production.yml --profile deployment --env-file prod.env up --force-recreate --build -d