forked from semgrep/semgrep
-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (114 loc) · 4.17 KB
/
build-test-docker.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Build and test our semgrep docker image.
name: build-test-docker
on:
workflow_dispatch:
inputs:
docker-flavor:
required: true
type: string
description: A multi-line string in the format accepted by docker metadata tag action for the flavor of the image. See https://github.com/docker/metadata-action#flavor-input for more information
docker-tags:
required: true
type: string
description: A multi-line string in the format accepted by docker metadata tag action for the tags to apply to the image. See https://github.com/docker/metadata-action#tags-input for more information
artifact-name:
required: true
type: string
description: Name (key) to use when uploading the docker image tarball as a artifact
repository-name:
required: true
type: string
description: The repository/name of the docker image to push, e.g., returntocorp/semgrep
default: returntocorp/semgrep
file:
required: true
type: string
description: Dockerfile to build
default: Dockerfile
target:
required: true
type: string
description: Dockerfile target to build
enable-tests:
required: true
type: boolean
description: Whether or not to run validation on the built image
workflow_call:
inputs:
docker-flavor:
required: true
type: string
description: A multi-line string in the format accepted by docker metadata tag action for the flavor of the image. See https://github.com/docker/metadata-action#flavor-input for more information
docker-tags:
required: true
type: string
description: A multi-line string in the format accepted by docker metadata tag action for the tags to apply to the image. See https://github.com/docker/metadata-action#tags-input for more information
artifact-name:
required: true
type: string
description: Name (key) to use when uploading the docker image tarball as a artifact
repository-name:
required: true
type: string
description: The repository/name of the docker image to push, e.g., returntocorp/semgrep
file:
required: true
type: string
description: Dockerfile to build
target:
required: true
type: string
description: Dockerfile target to build
enable-tests:
required: true
type: boolean
description: Whether or not to run validation on the built image
jobs:
build-test-docker:
name: Build and test Semgrep Docker image
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
strategy:
matrix:
architecture:
- amd64
- arm64
steps:
- if: ${{ matrix.architecture != 'amd64' }}
uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v2
- id: meta
name: Set tags and labels
uses: docker/metadata-action@v5
with:
images: ${{ inputs.repository-name }}
flavor: ${{ inputs.docker-flavor }}
tags: ${{ inputs.docker-tags }}
- uses: depot/setup-action@v1
- name: Build image
id: build-image
uses: depot/build-push-action@v1.9.0
with:
project: fhmxj6w9z8
platforms: linux/${{ matrix.architecture }}
outputs: type=docker,dest=/tmp/image.tar
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ${{ inputs.file }}
target: ${{ inputs.target }}
buildx-fallback: true
- name: Load image
if: ${{ inputs.enable-tests }}
run: |
docker load --input /tmp/image.tar
- uses: actions/checkout@v3
if: ${{ inputs.enable-tests }}
- name: Test Image
if: ${{ inputs.enable-tests }}
run: ./scripts/validate-docker-build.sh ${{ steps.build-image.outputs.imageid }} linux/${{ matrix.architecture }}
- uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact-name }}-arch-${{ matrix.architecture }}
path: /tmp/image.tar