Skip to content

Commit

Permalink
添加 github action 脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuweitung committed Oct 18, 2024
1 parent 071dee0 commit 8aa7c2a
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: build

on:
push:
tags:
- v*

jobs:
docker-release:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- Dockerfile: Dockerfile
steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'graalvm'
cache: maven
- name: Build with Maven
run: mvn -B clean package --file pom.xml

- name: Prepare
id: prepare
run: |
TAG=${GITHUB_REF#refs/tags/}
echo ::set-output name=full_tag_name::${TAG}
echo ::set-output name=latest_tag::latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and publish ${{ matrix.target.Dockerfile }}
uses: docker/build-push-action@v2
with:
context: .
push: true
builder: ${{ steps.buildx.outputs.name }}
file: ${{ matrix.target.Dockerfile }}
platforms: linux/amd64,linux/arm64,linux/arm
cache-from: type=gha,scope=${{ github.workflow }}
cache-to: type=gha,mode=max,scope=${{ github.workflow }}
tags: |
zhuweitung/jd-stock:${{ steps.prepare.outputs.full_tag_name }}
zhuweitung/jd-stock:${{ steps.prepare.outputs.latest_tag }}

0 comments on commit 8aa7c2a

Please sign in to comment.