Defaulers #75
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: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
build_images: | |
name: Build Docker Images | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push with Docker Compose | |
run: | | |
docker compose -f src/docker-compose.yml build | |
docker compose -f src/docker-compose.yml push | |
env: | |
DOCKER_BUILDKIT: 1 | |
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
copy_files: | |
name: Copy files to server | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: copy file via ssh password | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
password: ${{ secrets.SSH_KEY }} | |
source: src/docker-compose.yml, src/docker-compose.override.yml | |
target: /home/github-actions | |
update_server: | |
name: Deploy to Server | |
runs-on: ubuntu-latest | |
needs: build_images | |
steps: | |
- name: Replacing container | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
password: ${{ secrets.SSH_KEY }} | |
script: | | |
cd /home/github-actions/src | |
docker-compose down || true | |
docker image prune -a -f | |
docker-compose pull | |
docker-compose up -d | |
# ${{ github.run_number }} is an integer that increments with every run of the workflow in the repository. |