@@ -3,11 +3,63 @@ name: risc-v CI
3
3
on :
4
4
pull_request :
5
5
6
+ permissions :
7
+ contents : read
8
+ packages : write
9
+
6
10
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
+
7
58
build_and_test :
59
+ needs : build_ci_image
8
60
runs-on : ubuntu-latest
9
61
container :
10
- image : ghcr.io/utoss/risc-v:ci
62
+ image : ${{ needs.build_ci_image.outputs.image-tag }}
11
63
12
64
steps :
13
65
- name : Checkout code
0 commit comments