12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- name: DockerHub - Build & Push
- on:
- push:
- tags:
- - v*
- jobs:
- build:
- runs-on: ubuntu-22.04
- steps:
- - uses: actions/checkout@v4
- - name: Set up JDK 17
- uses: actions/setup-java@v4
- with:
- java-version: '17'
- distribution: 'temurin'
- cache: maven
- - name: Cache local Maven repository
- 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 -B package --file pom.xml -Dmaven.test.skip=true
- - name: Get Maven project version
- id: version
- run: |
- echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> "$GITHUB_OUTPUT"
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
- - name: Login to Docker Hub
- uses: docker/login-action@v3
- with:
- username: ${{ secrets.DOCKER_USERNAME }}
- password: ${{ secrets.DOCKER_PASSWORD }}
- - name: Build and push Docker image
- uses: docker/build-push-action@v5
- env:
- DOCKER_NAMESPACE: ${{ secrets.DOCKER_NAMESPACE }}
- VERSION: ${{ steps.version.outputs.version }}
- with:
- context: snail-job-server-starter/
- platforms: linux/amd64,linux/arm64
- push: true
- tags: |
- ${{ env.DOCKER_NAMESPACE }}/snail-job:latest
- ${{ env.DOCKER_NAMESPACE }}/snail-job:${{ env.VERSION }}
|