Skip to content

Commit 10ceb0e

Browse files
Add CI to build/push vehicle-mock
1 parent 7a79e02 commit 10ceb0e

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build & Push vehicle-mock
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ "main" ]
7+
paths:
8+
- "vehicle-mock/**"
9+
- ".github/workflows/build-vehicle-mock.yml"
10+
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
env:
16+
REGISTRY: ghcr.io
17+
18+
jobs:
19+
build-and-push:
20+
runs-on: ubuntu-22.04
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
# 解决 repo/owner 含大写导致的 GHCR/Docker 镜像名不合法问题:统一转小写
27+
- name: Resolve image name (lowercase)
28+
id: img
29+
shell: bash
30+
run: |
31+
OWNER_LC="$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')"
32+
REPO_LC="$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')"
33+
echo "image=${{ env.REGISTRY }}/${OWNER_LC}/${REPO_LC}-vehicle-mock" >> $GITHUB_OUTPUT
34+
35+
- name: Set up QEMU
36+
uses: docker/setup-qemu-action@v3
37+
38+
- name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v3
40+
41+
- name: Log in to GHCR
42+
uses: docker/login-action@v3
43+
with:
44+
registry: ${{ env.REGISTRY }}
45+
username: ${{ github.actor }}
46+
password: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: Build and push (arm64)
49+
uses: docker/build-push-action@v6
50+
with:
51+
context: ./vehicle-mock
52+
file: ./vehicle-mock/Dockerfile
53+
platforms: linux/arm64
54+
push: true
55+
tags: |
56+
${{ steps.img.outputs.image }}:dev
57+
${{ steps.img.outputs.image }}:${{ github.sha }}

0 commit comments

Comments
 (0)