Skip to content

Update docker-ci.yml #9

Update docker-ci.yml

Update docker-ci.yml #9

Workflow file for this run

name: Docker CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
inputs:
tags:
description: 'Manual Build'
required: false
jobs:
build-and-publish:
runs-on: ubuntu-latest
env:
IMAGE_NAME: ${{ secrets.DOCKER_HUB_USERNAME }}/chaoxing-clockin
steps:
- name: Get current date for Image Tag
id: date
run: echo "value=$(TZ='Asia/Shanghai' date +'%Y%m%d')" >> $GITHUB_OUTPUT
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
cache: 'maven'
- name: Build with Maven
run: mvn clean package
- name: Copy JAR file
run: cp target/*.jar app.jar
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and Push Image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ steps.date.outputs.value }}
${{ env.IMAGE_NAME }}:latest
- name: Update repo description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
repository: ${{ env.IMAGE_NAME }}
short-description: ${{ github.event.repository.description }}
- name: Push Summary
run: echo "### Build ${{ env.IMAGE_NAME }}:${{ steps.date.outputs.value }} Successfully :rocket:" >> $GITHUB_STEP_SUMMARY