Skip to content

Commit 912751b

Browse files
add ci image build step
1 parent ede04e8 commit 912751b

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,58 @@ on:
44
pull_request:
55

66
jobs:
7+
build_ci_image:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
image-tag: ${{ steps.meta.outputs.tags }}
11+
image-digest: ${{ steps.build.outputs.digest }}
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v3
19+
20+
- name: Login to GitHub Container Registry
21+
uses: docker/login-action@v3
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Extract metadata
28+
id: meta
29+
uses: docker/metadata-action@v5
30+
with:
31+
images: ghcr.io/utoss/risc-v
32+
tags: |
33+
type=ref,event=branch,prefix=ci-
34+
type=ref,event=pr,prefix=ci-
35+
type=raw,value=latest,prefix=ci,enable={{is_default_branch}}
36+
37+
- name: Build and push Docker image
38+
id: build
39+
uses: docker/build-push-action@v5
40+
with:
41+
context: .
42+
file: ./Dockerfile.ci
43+
push: true
44+
tags: ${{ steps.meta.outputs.tags }}
45+
labels: ${{ steps.meta.outputs.labels }}
46+
platforms: linux/amd64
47+
cache-from: |
48+
type=gha
49+
type=registry,ref=ghcr.io/utoss/risc-v:buildcache
50+
cache-to: |
51+
type=gha,mode=max
52+
type=registry,ref=ghcr.io/utoss/risc-v:buildcache,mode=max
53+
754
build_and_test:
55+
needs: build_ci_image
856
runs-on: ubuntu-latest
957
container:
10-
image: ghcr.io/utoss/risc-v:ci
58+
image: ${{ needs.build_ci_image.outputs.image-tag }}
1159

1260
steps:
1361
- name: Checkout code

0 commit comments

Comments
 (0)