docker file 更新: #16
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: publish-docker | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
dist-jar: | |
name: "Build dist jar" | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: "Cache Maven Repos" | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: "Set up JDK 17" | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: "temurin" | |
architecture: x64 | |
- name: "Build distribution tar" | |
run: | | |
mvn clean package -B -Dmaven.test.skip -Dcheckstyle.skip -Pprod | |
- uses: actions/upload-artifact@v3 | |
name: "Upload distribution tar" | |
with: | |
name: dist | |
path: dist | |
docker-images: | |
name: "Docker images" | |
needs: [ dist-jar ] | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/download-artifact@v3 | |
name: "Download distribution tar" | |
with: | |
name: dist | |
path: dist | |
- name: "Set environment variables" | |
run: | | |
echo "DOCKER_REGISTRY=docker.io" >> $GITHUB_ENV | |
echo "DOCKER_USERNAME=${{ secrets.DOCKERHUB_USER }}" >> $GITHUB_ENV | |
echo "DOCKER_PASSWORD=${{ secrets.DOCKERHUB_TOKEN }}" >> $GITHUB_ENV | |
echo "TAG=${{ github.ref_name }}" >> $GITHUB_ENV | |
- name: "Log in to the Container registry" | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY }} | |
username: ${{ env.DOCKER_USERNAME }} | |
password: ${{ env.DOCKER_PASSWORD }} | |
- name: "Set up Docker Buildx" | |
uses: docker/setup-buildx-action@v2 | |
- name: "Build and save docker images" | |
env: | |
BASE_IMAGE: eclipse-temurin:17-jre-jammy | |
run: | | |
make docker.push || make docker.push |