Docker Image CI #160
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Image CI | |
on: | |
workflow_run: | |
workflows: ["Lint, Test and Build"] | |
types: | |
- completed | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Checkout repository and submodules | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- id: docker-build | |
uses: ./.github/actions/docker-build | |
with: | |
vps-host: ${{ secrets.API_HOST_PROD }} | |
vue-app-api-ver: ${{ secrets.VUE_APP_API_VER }} | |
docker-hub-username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
docker-hub-access-token: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
push: 'true' | |
- name: Image digest | |
run: echo ${{ steps.docker-build.outputs.docker-build-digest }} | |
- name: Actualize docker images on VPS | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.VPS_HOST }} | |
username: ${{ secrets.VPS_USERNAME }} | |
key: ${{ secrets.VPS_SSH_KEY }} | |
passphrase: ${{ secrets.VPS_SSH_KEY_PASSPHRASE }} | |
script_stop: true | |
script: | | |
cd ${{ secrets.VPS_PROJECT_PATH }} | |
# Pull the latest image | |
docker-compose pull | |
# Start the new containers without dependencies, so there will be almost | |
# no downtime | |
docker-compose up -d --no-deps |