style: standardize code style and optimize CI pipeline

- Change single quotes to double quotes for consistency
- Consolidate job steps by removing unnecessary hyphens
- Add caching options for Docker build and push actions

Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
appleboy
2024-06-01 10:50:11 +08:00
parent c1ebb32673
commit 9a56c98766
+12 -16
View File
@@ -5,10 +5,10 @@ on:
branches:
- master
tags:
- 'v*'
- "v*"
pull_request:
branches:
- 'master'
- "master"
jobs:
build-docker:
@@ -17,42 +17,37 @@ jobs:
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '^1'
go-version: "^1"
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build binary
run : |
run: |
make build_linux_amd64
make build_linux_arm
make build_linux_arm64
-
name: Set up QEMU
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GitHub Container Registry
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Docker meta
- name: Docker meta
id: docker-meta
uses: docker/metadata-action@v4
with:
@@ -65,8 +60,7 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
-
name: Build and push
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
@@ -75,3 +69,5 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker-meta.outputs.tags }}
labels: ${{ steps.docker-meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max