50 lines
1.4 KiB
YAML
50 lines
1.4 KiB
YAML
name: Build and Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build_docker_image:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out repository code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Extract package version from package.json
|
|
id: version
|
|
run: |
|
|
VERSION=$(node -p "require('./package.json').version")
|
|
echo "package_version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Login to Docker Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.marinodev.com
|
|
username: ${{ vars.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Build and Push Docker Image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
pull: true
|
|
push: true
|
|
no-cache: true
|
|
tags: |
|
|
git.marinodev.com/marinodev/lindner_visitor:latest
|
|
git.marinodev.com/marinodev/lindner_visitor:${{ steps.version.outputs.package_version }}
|
|
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
needs: docker_image
|
|
steps:
|
|
- name: Restart Service
|
|
uses: https://github.com/appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ vars.DEPLOY_HOST }}
|
|
username: ${{ vars.DEPLOY_USER }}
|
|
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
script: |
|
|
cd ${{ vars.DEPLOY_PATH }}
|
|
docker-compose down && docker-compose pull && docker-compose up -d |