Skip to content

fixbug: 修复workflow #11

fixbug: 修复workflow

fixbug: 修复workflow #11

Workflow file for this run

name: BuildImage
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
cache: true
- name: Set variables
id: vars
shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "time=$(TZ=Asia/Shanghai date +'%Y%m%d')" >> $GITHUB_OUTPUT
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Go mod cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build
run: |
go mod tidy
go build -v .
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
file: ./coverage.txt
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.REGISTRY_URL }}/serverless2025/http_bench:latest
${{ secrets.REGISTRY_URL }}/serverless2025/http_bench:${{ steps.vars.outputs.tag }}
${{ secrets.REGISTRY_URL }}/serverless2025/http_bench:${{ steps.vars.outputs.tag }}-${{ steps.vars.outputs.time }}
cache-from: type=gha
cache-to: type=gha,mode=max