Skip to content

Remove Docker Buildx setup step from server CI #75

Remove Docker Buildx setup step from server CI

Remove Docker Buildx setup step from server CI #75

Workflow file for this run

name: Backend - build and deploy
on:
push:
branches:
- main
paths:
- "server/**" # limit workflow only to changes in backend folder
- ".github/workflows/server-cd.yml"
pull_request:
branches:
- main
paths:
- "server/**"
- ".github/workflows/server-cd.yml"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout current repository
uses: actions/checkout@v3
- name: set up Java 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: build application jar
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
arguments: build
build-root-directory: server
- name: create server artifact from jar
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v3
with:
name: server
path: server/build
- name: build and publish server Docker image
uses: docker/build-push-action@v4
with:
context: server
file: server/docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: false
tags: stenal/baltic-stock-server:latest
publish:
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: checkout current repository
uses: actions/checkout@v3
- name: download server artifact
uses: actions/download-artifact@v3
with:
name: server
path: server/build
- name: log in to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: build and publish server Docker image
uses: docker/build-push-action@v4
with:
context: server
file: server/docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: stenal/baltic-stock-server:latest
- name: deploy production docker-compose.yml
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
source: "server/docker/prod/docker-compose.yml"
target: "~"
strip_components: 3
- name: Deploy published images
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
docker compose pull
docker compose up -d