|
4 | 4 | pull_request:
|
5 | 5 |
|
6 | 6 | 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 | +
|
7 | 54 | build_and_test:
|
| 55 | + needs: build_ci_image |
8 | 56 | runs-on: ubuntu-latest
|
9 | 57 | container:
|
10 |
| - image: ghcr.io/utoss/risc-v:ci |
| 58 | + image: ${{ needs.build_ci_image.outputs.image-tag }} |
11 | 59 |
|
12 | 60 | steps:
|
13 | 61 | - name: Checkout code
|
|
0 commit comments