Skip to content

Commit 86c2f24

Browse files
add ci image build step
1 parent ede04e8 commit 86c2f24

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,63 @@ name: risc-v CI
33
on:
44
pull_request:
55

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

1264
steps:
1365
- name: Checkout code

0 commit comments

Comments
 (0)