|
1 | | -name: Build and Release |
| 1 | +name: Build and Release Helm Chart |
2 | 2 | on: |
3 | | - push: |
4 | | - branches: |
5 | | - - '*' |
6 | 3 | pull_request: |
7 | 4 | branches: |
8 | 5 | - 'v*' |
|
14 | 11 | # pushed to the pull request's branch |
15 | 12 | - synchronize |
16 | 13 |
|
17 | | -env: |
18 | | - REGISTRY: ghcr.io |
19 | | - |
20 | 14 | jobs: |
21 | | - build: |
22 | | - name: Build Containers |
23 | | - runs-on: ubuntu-latest |
24 | | - strategy: |
25 | | - fail-fast: false |
26 | | - matrix: |
27 | | - platform: |
28 | | - - linux/arm64 |
29 | | - - linux/amd64 |
30 | | - - linux/s390x |
31 | | - - linux/ppc64le |
32 | | - |
33 | | - permissions: |
34 | | - contents: read |
35 | | - packages: write |
36 | | - |
37 | | - steps: |
38 | | - |
39 | | - - name: Set IMAGE_NAME |
40 | | - run: | |
41 | | - echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} |
42 | | -
|
43 | | - # Checkout code |
44 | | - # https://github.com/actions/checkout |
45 | | - - name: Checkout code |
46 | | - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 |
47 | | - |
48 | | - # Extract metadata (tags, labels) for Docker |
49 | | - # https://github.com/docker/metadata-action |
50 | | - - name: Extract Docker metadata |
51 | | - id: meta |
52 | | - uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 |
53 | | - with: |
54 | | - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
55 | | - |
56 | | - # Set up QEMU |
57 | | - # https://github.com/docker/setup-qemu-action |
58 | | - - name: Set up QEMU |
59 | | - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 |
60 | | - |
61 | | - # Set up BuildKit Docker container builder to be able to build |
62 | | - # multi-platform images and export cache |
63 | | - # https://github.com/docker/setup-buildx-action |
64 | | - - name: Set up Docker Buildx |
65 | | - uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 |
66 | | - |
67 | | - # Login to Docker registry |
68 | | - # https://github.com/docker/login-action |
69 | | - - name: Log into registry ${{ env.REGISTRY }} |
70 | | - uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 |
71 | | - with: |
72 | | - registry: ${{ env.REGISTRY }} |
73 | | - username: ${{ github.actor }} |
74 | | - password: ${{ secrets.GITHUB_TOKEN }} |
75 | | - |
76 | | - # Build and push Docker image with Buildx |
77 | | - # https://github.com/docker/build-push-action |
78 | | - - name: Build and push Docker image |
79 | | - id: build |
80 | | - uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 |
81 | | - with: |
82 | | - context: . |
83 | | - platforms: ${{ matrix.platform }} |
84 | | - labels: ${{ steps.meta.outputs.labels }} |
85 | | - push: ${{ github.event.pull_request.merged == true }} |
86 | | - outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true |
87 | | - |
88 | | - # Export digest |
89 | | - - name: Export digest |
90 | | - if: github.event.pull_request.merged == true |
91 | | - run: | |
92 | | - mkdir -p /tmp/digests |
93 | | - digest="${{ steps.build.outputs.digest }}" |
94 | | - touch "/tmp/digests/${digest#sha256:}" |
95 | | -
|
96 | | - # Upload digest |
97 | | - - name: Upload digest |
98 | | - if: github.event.pull_request.merged == true |
99 | | - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 |
100 | | - with: |
101 | | - name: digests |
102 | | - path: /tmp/digests/* |
103 | | - if-no-files-found: error |
104 | | - retention-days: 1 |
105 | | - |
106 | | - merge: |
107 | | - runs-on: ubuntu-latest |
108 | | - if: github.event.pull_request.merged == true |
109 | | - needs: |
110 | | - - build |
111 | | - steps: |
112 | | - - name: Set IMAGE_NAME |
113 | | - run: | |
114 | | - echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} |
115 | | -
|
116 | | - # Download digests |
117 | | - # https://github.com/actions/download-artifact |
118 | | - - name: Download digests |
119 | | - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 |
120 | | - with: |
121 | | - name: digests |
122 | | - path: /tmp/digests |
123 | | - |
124 | | - # Set up BuildKit Docker container builder to be able to build |
125 | | - # multi-platform images and export cache |
126 | | - # https://github.com/docker/setup-buildx-action |
127 | | - - name: Set up Docker Buildx |
128 | | - uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 |
129 | | - |
130 | | - # Extract metadata (tags, labels) for Docker |
131 | | - # https://github.com/docker/metadata-action |
132 | | - - name: Extract Docker metadata |
133 | | - id: meta |
134 | | - uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 |
135 | | - with: |
136 | | - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
137 | | - |
138 | | - # Login to Docker registry |
139 | | - # https://github.com/docker/login-action |
140 | | - - name: Log into registry ${{ env.REGISTRY }} |
141 | | - uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 |
142 | | - with: |
143 | | - registry: ${{ env.REGISTRY }} |
144 | | - username: ${{ github.actor }} |
145 | | - password: ${{ secrets.GITHUB_TOKEN }} |
146 | | - |
147 | | - # Create manifest list and push |
148 | | - - name: Create manifest list and push |
149 | | - working-directory: /tmp/digests |
150 | | - run: | |
151 | | - docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
152 | | - $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) |
153 | | -
|
154 | | - - name: Inspect image |
155 | | - run: | |
156 | | - docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }} |
157 | | -
|
158 | 15 | helm: |
159 | 16 | runs-on: ubuntu-latest |
160 | 17 | if: github.event.pull_request.merged == true |
161 | | - needs: |
162 | | - - merge |
163 | 18 | steps: |
164 | 19 | - name: Set IMAGE_NAME |
165 | 20 | run: | |
|
0 commit comments