|
1 | 1 | name: ci |
2 | 2 |
|
3 | | -concurrency: |
4 | | - group: ${{ github.event_name }}-${{ github.ref_name }} |
5 | | - cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') }} |
6 | | - |
7 | 3 | on: |
8 | 4 | pull_request: |
9 | 5 | branches: |
|
14 | 10 | tags: |
15 | 11 | - "*" |
16 | 12 |
|
17 | | -env: |
18 | | - IMAGE_REPOSITORY: ${{ github.repository }} |
19 | | - IMAGE_REGISTRY: ghcr.io |
20 | | - |
21 | 13 | jobs: |
22 | | - build-docker-pr: |
23 | | - if: github.event_name == 'pull_request' |
24 | | - permissions: |
25 | | - contents: read |
26 | | - packages: write |
27 | | - pull-requests: write |
| 14 | + build-edge: |
| 15 | + if: | |
| 16 | + contains(fromJson('["push","pull_request"]'), github.event_name) && |
| 17 | + github.ref == 'refs/heads/main' |
28 | 18 | runs-on: ubuntu-latest |
29 | 19 | steps: |
30 | | - - name: Checkout |
31 | | - uses: actions/checkout@v4 |
32 | | - - name: Set up QEMU |
33 | | - uses: docker/setup-qemu-action@v3 |
34 | | - - name: Set up Docker Buildx |
35 | | - uses: docker/setup-buildx-action@v3 |
36 | | - - name: Login to Docker Container Registry |
37 | | - uses: docker/login-action@v3 |
38 | | - with: |
39 | | - username: ${{ secrets.DOCKERHUB_USERNAME }} |
40 | | - password: ${{ secrets.DOCKERHUB_PASSWORD }} |
41 | | - - name: Login to GitHub Container Registry |
42 | | - uses: docker/login-action@v3 |
43 | | - with: |
44 | | - password: ${{ secrets.GITHUB_TOKEN }} |
45 | | - registry: ghcr.io |
46 | | - username: ${{ github.actor }} |
47 | | - - id: meta |
48 | | - name: Docker metadata |
49 | | - uses: docker/metadata-action@v5 |
50 | | - with: |
51 | | - images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }} |
52 | | - - name: Build and push |
53 | | - uses: docker/build-push-action@v6 |
54 | | - with: |
55 | | - cache-from: type=gha |
56 | | - cache-to: type=gha,mode=max |
57 | | - labels: ${{ steps.meta.outputs.labels }} |
58 | | - platforms: linux/amd64,linux/arm64 |
59 | | - push: true |
60 | | - tags: | |
61 | | - ${{ steps.meta.outputs.tags }} |
62 | | - ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}:${{ github.run_id }} |
63 | | - - if: contains(github.event.pull_request.labels.*.name, 'check-cves') |
64 | | - name: Docker Scout - cves |
65 | | - uses: docker/scout-action@v1 |
66 | | - with: |
67 | | - command: cves |
68 | | - ignore-unchanged: true |
69 | | - image: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}:${{ github.run_id }} |
70 | | - only-fixed: true |
71 | | - only-severities: medium,high,critical |
72 | | - sarif-file: sarif.output.json |
73 | | - summary: true |
74 | | - - if: contains(github.event.pull_request.labels.*.name, 'check-cves') |
75 | | - name: Upload artifact |
76 | | - uses: actions/upload-artifact@v4 |
77 | | - with: |
78 | | - if-no-files-found: warn |
79 | | - name: scout-results |
80 | | - path: sarif.output.json |
| 20 | + - name: Build docker |
| 21 | + uses: meysam81/build-docker@main |
| 22 | + with: |
| 23 | + cosign: true |
| 24 | + image-extra-tags: | |
| 25 | + ghcr.io/${{ github.repository }}:${{ github.run_id }} |
| 26 | + ghcr.io/${{ github.repository }}:latest |
| 27 | + image-name: ghcr.io/${{ github.repository }} |
| 28 | + kubescape: true |
| 29 | + kubescape-upload-sarif: true |
81 | 30 |
|
82 | | - build-docker-edge: |
| 31 | + semantic-release: |
83 | 32 | if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
84 | | - permissions: |
85 | | - contents: read |
86 | | - packages: write |
87 | | - security-events: write |
88 | 33 | runs-on: ubuntu-latest |
89 | | - steps: |
90 | | - - name: Checkout |
91 | | - uses: actions/checkout@v4 |
92 | | - - name: Set up QEMU |
93 | | - uses: docker/setup-qemu-action@v3 |
94 | | - - name: Set up Docker Buildx |
95 | | - uses: docker/setup-buildx-action@v3 |
96 | | - - name: Login to Docker Container Registry |
97 | | - uses: docker/login-action@v3 |
98 | | - with: |
99 | | - username: ${{ secrets.DOCKERHUB_USERNAME }} |
100 | | - password: ${{ secrets.DOCKERHUB_PASSWORD }} |
101 | | - - name: Login to GitHub Container Registry |
102 | | - uses: docker/login-action@v3 |
103 | | - with: |
104 | | - password: ${{ secrets.GITHUB_TOKEN }} |
105 | | - registry: ghcr.io |
106 | | - username: ${{ github.actor }} |
107 | | - - id: meta |
108 | | - name: Docker metadata |
109 | | - uses: docker/metadata-action@v5 |
110 | | - with: |
111 | | - images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }} |
112 | | - - name: Build and push |
113 | | - uses: docker/build-push-action@v6 |
114 | | - with: |
115 | | - cache-from: type=gha |
116 | | - cache-to: type=gha,mode=max |
117 | | - labels: ${{ steps.meta.outputs.labels }} |
118 | | - platforms: linux/amd64,linux/arm64 |
119 | | - push: true |
120 | | - tags: | |
121 | | - ${{ steps.meta.outputs.tags }} |
122 | | - ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}:${{ github.run_id }} |
123 | | - ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}:latest |
124 | | - - name: Docker Scout - cves |
125 | | - uses: docker/scout-action@v1 |
126 | | - with: |
127 | | - command: cves |
128 | | - ignore-unchanged: true |
129 | | - image: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}:${{ github.run_id }} |
130 | | - only-fixed: true |
131 | | - only-severities: medium,high,critical |
132 | | - sarif-file: sarif.output.json |
133 | | - summary: true |
134 | | - - name: Upload artifact |
135 | | - uses: actions/upload-artifact@v4 |
136 | | - with: |
137 | | - if-no-files-found: warn |
138 | | - name: scout-results |
139 | | - path: sarif.output.json |
140 | | - |
141 | | - build-docker-stable: |
142 | | - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') |
143 | 34 | permissions: |
144 | | - contents: read |
| 35 | + contents: write |
145 | 36 | packages: write |
146 | | - runs-on: ubuntu-latest |
| 37 | + issues: write |
| 38 | + pull-requests: write |
| 39 | + id-token: write |
147 | 40 | steps: |
148 | 41 | - name: Checkout |
149 | 42 | uses: actions/checkout@v4 |
150 | | - - name: Set up QEMU |
151 | | - uses: docker/setup-qemu-action@v3 |
152 | | - - name: Set up Docker Buildx |
153 | | - uses: docker/setup-buildx-action@v3 |
154 | | - - name: Login to Docker Container Registry |
155 | | - uses: docker/login-action@v3 |
156 | | - with: |
157 | | - username: ${{ secrets.DOCKERHUB_USERNAME }} |
158 | | - password: ${{ secrets.DOCKERHUB_PASSWORD }} |
159 | | - - name: Login to GitHub Container Registry |
160 | | - uses: docker/login-action@v3 |
161 | | - with: |
162 | | - password: ${{ secrets.GITHUB_TOKEN }} |
163 | | - registry: ghcr.io |
164 | | - username: ${{ github.actor }} |
165 | | - - id: meta |
166 | | - name: Docker metadata |
167 | | - uses: docker/metadata-action@v5 |
168 | 43 | with: |
169 | | - images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }} |
170 | | - - name: Build and push |
171 | | - uses: docker/build-push-action@v6 |
| 44 | + fetch-depth: 0 |
| 45 | + - name: Setup bun |
| 46 | + uses: oven-sh/setup-bun@v2 |
172 | 47 | with: |
173 | | - cache-from: type=gha |
174 | | - cache-to: type=gha,mode=max |
175 | | - labels: ${{ steps.meta.outputs.labels }} |
176 | | - platforms: linux/amd64,linux/arm64 |
177 | | - push: true |
178 | | - tags: | |
179 | | - ${{ steps.meta.outputs.tags }} |
180 | | - ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}:${{ github.ref_name }} |
181 | | - - name: Docker Scout - cves |
182 | | - uses: docker/scout-action@v1 |
183 | | - with: |
184 | | - command: cves |
185 | | - ignore-unchanged: true |
186 | | - image: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}:${{ github.ref_name }} |
187 | | - only-fixed: true |
188 | | - only-severities: medium,high,critical |
189 | | - sarif-file: sarif.output.json |
190 | | - summary: true |
191 | | - - name: Upload artifact |
192 | | - uses: actions/upload-artifact@v4 |
193 | | - with: |
194 | | - if-no-files-found: warn |
195 | | - name: scout-results |
196 | | - path: sarif.output.json |
197 | | - |
198 | | - github-release: |
199 | | - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') |
200 | | - permissions: |
201 | | - contents: write |
202 | | - runs-on: ubuntu-latest |
203 | | - steps: |
204 | | - - name: Checkout |
205 | | - uses: actions/checkout@v4 |
206 | | - - continue-on-error: true |
| 48 | + bun-version: latest |
| 49 | + - name: Install bun deps |
| 50 | + run: bun install |
| 51 | + - id: semantic-release |
| 52 | + name: Release |
207 | 53 | env: |
208 | | - GH_TOKEN: ${{ github.token }} |
209 | | - name: Create release |
210 | | - run: | |
211 | | - gh release create ${{ github.ref_name }} -t ${{ github.ref_name }} --generate-notes |
| 54 | + GITHUB_TOKEN: ${{ github.token }} |
| 55 | + run: bunx semantic-release@v24 |
| 56 | + - if: steps.semantic-release.outputs.version != '' |
| 57 | + name: Build docker |
| 58 | + uses: meysam81/build-docker@main |
| 59 | + with: |
| 60 | + cosign: true |
| 61 | + image-extra-tags: | |
| 62 | + ghcr.io/${{ github.repository }}:${{ steps.semantic-release.outputs.version }} |
| 63 | + image-name: ghcr.io/${{ github.repository }} |
| 64 | + kubescape: true |
| 65 | + kubescape-upload-sarif: true |
| 66 | + ref: ${{ steps.semantic-release.outputs.version }} |
0 commit comments