added Gitea action deploy.yml to deploy containers to my VM
This commit is contained in:
parent
353ea75ef6
commit
758fa8c4e8
1 changed files with 37 additions and 0 deletions
37
.gitea/workflows/deploy.yml
Normal file
37
.gitea/workflows/deploy.yml
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
name: Deploy Docker Container
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: ["Build and Push Docker Image"]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- dev
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.workflow_run.head_branch }}
|
||||||
|
|
||||||
|
- name: Deploy to Docker
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/deploy_key
|
||||||
|
chmod 600 ~/.ssh/deploy_key
|
||||||
|
ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
BRANCH="${{ github.event.workflow_run.head_branch }}"
|
||||||
|
DEPLOY_PATH="${{ secrets.DEPLOY_PATH }}"
|
||||||
|
|
||||||
|
ssh -i ~/.ssh/deploy_key ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} << EOF
|
||||||
|
cd ${DEPLOY_PATH}
|
||||||
|
docker-compose pull lcc-app-${BRANCH}
|
||||||
|
docker-compose --profile ${BRANCH} up -d lcc-app-${BRANCH}
|
||||||
|
EOF
|
||||||
Loading…
Add table
Reference in a new issue