feat: Add CI/CD workflow for testing/production branch deployments
Some checks are pending
Deploy Elmeg / deploy (push) Waiting to run
Some checks are pending
Deploy Elmeg / deploy (push) Waiting to run
This commit is contained in:
parent
2c9bf53407
commit
29c2033bca
1 changed files with 41 additions and 0 deletions
41
.forgejo/workflows/deploy.yml
Normal file
41
.forgejo/workflows/deploy.yml
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
name: Deploy Elmeg
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- testing
|
||||
- production
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set deployment target
|
||||
id: target
|
||||
run: |
|
||||
if [ "${{ github.ref_name }}" = "testing" ]; then
|
||||
echo "server=nexus-vector" >> $GITHUB_OUTPUT
|
||||
echo "domain=elmeg.runfoo.run" >> $GITHUB_OUTPUT
|
||||
elif [ "${{ github.ref_name }}" = "production" ]; then
|
||||
echo "server=tangible-aacorn" >> $GITHUB_OUTPUT
|
||||
echo "domain=elmeg.xyz" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Deploy to ${{ steps.target.outputs.server }}
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ steps.target.outputs.server == 'nexus-vector' && '216.158.230.94' || '159.69.219.254' }}
|
||||
username: root
|
||||
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
script: |
|
||||
cd /srv/containers/elmeg-demo
|
||||
git fetch origin ${{ github.ref_name }}
|
||||
git checkout ${{ github.ref_name }}
|
||||
git reset --hard origin/${{ github.ref_name }}
|
||||
docker compose build --no-cache
|
||||
docker compose up -d
|
||||
docker compose exec -T backend alembic upgrade head
|
||||
echo "Deployed ${{ github.ref_name }} to ${{ steps.target.outputs.domain }}"
|
||||
Loading…
Add table
Reference in a new issue