37 lines
No EOL
1 KiB
YAML
37 lines
No EOL
1 KiB
YAML
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 |