|
1 | | -name: ci |
| 1 | +name: CI Pipeline |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
|
13 | 13 | - "main" |
14 | 14 | - "dev" |
15 | 15 |
|
16 | | -env: |
17 | | - REGISTRY: ghcr.io |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + packages: write |
18 | 19 |
|
19 | 20 | jobs: |
20 | 21 | build: |
21 | | - runs-on: ubuntu-latest |
22 | 22 | strategy: |
23 | 23 | fail-fast: false |
24 | 24 | matrix: |
25 | | - include: |
| 25 | + config: |
26 | 26 | - platform: linux/amd64 |
27 | 27 | base: distroless |
| 28 | + runs-on: ubuntu-24.04 |
| 29 | + use-qemu: false |
28 | 30 | - platform: linux/arm/v6 |
29 | 31 | base: alpine |
| 32 | + runs-on: ubuntu-22.04-arm |
| 33 | + use-qemu: true |
30 | 34 | - platform: linux/arm/v7 |
31 | 35 | base: alpine |
| 36 | + runs-on: ubuntu-22.04-arm |
| 37 | + use-qemu: true |
32 | 38 | - platform: linux/arm64 |
33 | 39 | base: distroless |
34 | | - permissions: |
35 | | - contents: read |
36 | | - packages: write |
37 | | - steps: |
38 | | - - name: Checkout |
39 | | - uses: actions/checkout@v4 |
40 | | - - name: Set up QEMU |
41 | | - uses: docker/setup-qemu-action@v3 |
42 | | - - id: lower-repo |
43 | | - run: | |
44 | | - echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT |
45 | | - - name: Extract metadata (tags, labels) for Docker |
46 | | - id: meta |
47 | | - uses: docker/metadata-action@v5 |
48 | | - with: |
49 | | - images: ${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }} |
50 | | - - name: Set up Docker Buildx |
51 | | - uses: docker/setup-buildx-action@v3 |
52 | | - - name: Log in to the Container registry |
53 | | - uses: docker/login-action@v3 |
54 | | - with: |
55 | | - registry: ${{ env.REGISTRY }} |
56 | | - username: ${{ github.actor }} |
57 | | - password: ${{ secrets.GITHUB_TOKEN }} |
58 | | - - name: Build |
59 | | - if: github.event_name == 'pull_request' |
60 | | - id: build |
61 | | - uses: docker/build-push-action@v5 |
62 | | - with: |
63 | | - context: . |
64 | | - platforms: ${{ matrix.platform }} |
65 | | - file: ./Dockerfile |
66 | | - labels: ${{ steps.meta.outputs.labels }} |
67 | | - outputs: type=docker,name=${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }} |
68 | | - build-args: BASE=${{ matrix.base }} |
69 | | - - name: Build and push |
70 | | - if: github.event_name != 'pull_request' |
71 | | - id: build_push |
72 | | - uses: docker/build-push-action@v5 |
73 | | - with: |
74 | | - context: . |
75 | | - platforms: ${{ matrix.platform }} |
76 | | - file: ./Dockerfile |
77 | | - labels: ${{ steps.meta.outputs.labels }} |
78 | | - outputs: type=image,name=${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true |
79 | | - build-args: BASE=${{ matrix.base }} |
80 | | - - name: Export digest |
81 | | - if: github.event_name != 'pull_request' |
82 | | - run: | |
83 | | - mkdir -p /tmp/digests |
84 | | - digest="${{ steps.build_push.outputs.digest }}" |
85 | | - touch "/tmp/digests/${digest#sha256:}" |
86 | | - - name: Upload digest |
87 | | - if: github.event_name != 'pull_request' |
88 | | - uses: actions/upload-artifact@v4 |
89 | | - with: |
90 | | - name: digests |
91 | | - path: /tmp/digests/* |
92 | | - if-no-files-found: error |
93 | | - retention-days: 1 |
94 | | - overwrite: true |
| 40 | + runs-on: ubuntu-24.04-arm |
| 41 | + use-qemu: false |
| 42 | + uses: ./.github/workflows/build-image.yml |
| 43 | + with: |
| 44 | + registry: ghcr.io |
| 45 | + platform: ${{ matrix.config.platform }} |
| 46 | + base: ${{ matrix.config.base }} |
| 47 | + runs-on: ${{ matrix.config.runs-on }} |
| 48 | + use-qemu: ${{ matrix.config.use-qemu }} |
| 49 | + context: . |
| 50 | + dockerfile: ./Dockerfile |
| 51 | + image-suffix: "" |
| 52 | + digest-prefix: "digests-base-" |
95 | 53 |
|
96 | 54 | merge: |
97 | | - runs-on: ubuntu-latest |
98 | 55 | if: github.event_name != 'pull_request' |
99 | | - permissions: |
100 | | - contents: read |
101 | | - packages: write |
102 | 56 | needs: |
103 | 57 | - build |
104 | | - steps: |
105 | | - - name: Download digests |
106 | | - uses: actions/download-artifact@v4 |
107 | | - with: |
108 | | - name: digests |
109 | | - path: /tmp/digests |
110 | | - - name: Set up Docker Buildx |
111 | | - uses: docker/setup-buildx-action@v3 |
112 | | - - id: lower-repo |
113 | | - run: | |
114 | | - echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT |
115 | | - - name: Extract metadata (tags, labels) for Docker |
116 | | - id: meta |
117 | | - uses: docker/metadata-action@v5 |
118 | | - with: |
119 | | - images: ${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }} |
120 | | - - name: Log in to the Container registry |
121 | | - uses: docker/login-action@v3 |
122 | | - with: |
123 | | - registry: ${{ env.REGISTRY }} |
124 | | - username: ${{ github.actor }} |
125 | | - password: ${{ secrets.GITHUB_TOKEN }} |
126 | | - - name: Create manifest list and push |
127 | | - working-directory: /tmp/digests |
128 | | - run: | |
129 | | - docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
130 | | - $(printf '${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }}@sha256:%s ' *) |
131 | | - - name: Inspect image |
132 | | - run: | |
133 | | - docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }}:${{ steps.meta.outputs.version }} |
| 58 | + uses: ./.github/workflows/merge-manifests.yml |
| 59 | + with: |
| 60 | + registry: ghcr.io |
| 61 | + image-suffix: "" |
| 62 | + digest-prefix: "digests-base-" |
134 | 63 |
|
135 | 64 | lint: |
136 | 65 | runs-on: ubuntu-latest |
|
0 commit comments