ci: deployment test #38
Workflow file for this run
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: Build with docker | |
on: [push, pull_request] | |
jobs: | |
build-docker: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver: docker | |
- name: Build production environment using docker-compose | |
run: | | |
docker-compose -f docker-compose.yml build production | |
- name: Save Docker image as a tarball | |
run: docker save bxt_production:latest -o bxt-production.tar | |
- name: Upload Docker image to artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bxt-production-image | |
path: | | |
bxt-production.tar | |
docker-compose.yml | |
deploy-ssh: | |
name: Deploy to server using ssh | |
needs: build-docker | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Docker image from artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: bxt-production-image | |
path: distfiles | |
- name: Transfer Docker image to server | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.DEPLOYMENT_SERVER_HOST }} | |
username: ${{ secrets.DEPLOYMENT_SERVER_USER }} | |
key: ${{ secrets.DEPLOYMENT_SERVER_SSH_KEY }} | |
source: distfiles/* | |
target: "/tmp/bxt/" | |
- name: Deploy Docker image on server | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.DEPLOYMENT_SERVER_HOST }} | |
username: ${{ secrets.DEPLOYMENT_SERVER_USER }} | |
key: ${{ secrets.DEPLOYMENT_SERVER_SSH_KEY }} | |
script: | | |
docker-compose -f /tmp/bxt/docker-compose.yml stop || true | |
docker load -i /tmp/bxt/bxt-production.tar | |
docker-compose -f /tmp/bxt/docker-compose.yml up production |