Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define a job to change version tag in code upon release #583

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .github/workflows/deploy_prod.yaml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/deploy_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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
uses: EndBug/add-and-commit@v9
with:
default_author: github_actor
message: 'Bump version automatically on release'
add: './app/main.py'
push: 'origin HEAD:version-2 --force'

- name: Move release tag to latest commit
run: |
git tag -a $(git describe --tags --abbrev=0) -m "moving tag to new commit" -f $(git rev-parse HEAD)
git config --global user.name 'Gitactions bot'
git config --global user.email '<>'
git push -f origin refs/tags/$(git describe --tags --abbrev=0)

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 --profile deployment --env-file prod.env up --force-recreate --build -d