mirror of
https://gitea.gofwd.group/Forward_Group/ballistic-builder-spring.git
synced 2026-01-20 16:51:03 -05:00
platform stuf, more praactice than productivity
This commit is contained in:
60
docker/.github/workflows/docker-deploy.yml
vendored
Normal file
60
docker/.github/workflows/docker-deploy.yml
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
name: Build, Dockerize and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
env:
|
||||
IMAGE: ${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }}
|
||||
|
||||
jobs:
|
||||
build-and-publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
|
||||
- name: Cache Maven
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-m2-
|
||||
|
||||
- name: Build with Maven (skip tests)
|
||||
run: mvn -B package -DskipTests
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build Docker image
|
||||
run: docker build -t $IMAGE .
|
||||
|
||||
- name: Push Docker image
|
||||
run: docker push $IMAGE
|
||||
|
||||
deploy:
|
||||
needs: build-and-publish
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Deploy to remote via SSH
|
||||
uses: appleboy/ssh-action@v0.1.7
|
||||
with:
|
||||
host: ${{ secrets.REMOTE_HOST }}
|
||||
username: ${{ secrets.REMOTE_USER }}
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
script: |
|
||||
docker pull $IMAGE
|
||||
docker stop app || true
|
||||
docker rm app || true
|
||||
docker run -d --name app -p 8080:8080 --restart unless-stopped $IMAGE
|
||||
Reference in New Issue
Block a user