Skip to content

refactored

refactored #9

Workflow file for this run

name: Build and Push Docker Image
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'adopt'
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn clean package
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log-in to registry
uses: docker/login-action@v3
with:
registry: https://index.docker.io/v1/
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push container image to registry
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: index.docker.io/${{ secrets.DOCKER_USERNAME }}/zplex-api:${{ github.sha }}