-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (88 loc) · 3.55 KB
/
build-scan-push.yml
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
name: datadog-build-scan-push
on:
push:
branches:
- main
env:
REGISTRY: ghcr.io
AGENT_VERSION: 7.55.2
CLUSTER_AGENT_IMAGE_NAME: "${{ github.repository }}/datadog-cluster-agent:${{ github.sha }}-7.55.2-GOV"
AGENT_IMAGE_NAME: "${{ github.repository }}/datadog-agent:${{ github.sha }}-7.55.2-GOV"
jobs:
build-and-scan:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install python
uses: actions/setup-python@v4
with:
python-version: "3.8.14"
- name: Install Python requirements
run: |
pip install -r requirements.txt
- name: Setup env variables
run: |
echo "CODEQL_PYTHON=$(which python3)" >> $GITHUB_ENV
echo "$GOPATH/bin" >> $GITHUB_PATH
echo "CGO_LDFLAGS= -L${GITHUB_WORKSPACE}/rtloader/build/rtloader -ldl " >> $GITHUB_ENV
echo "CGO_CFLAGS= -I${GITHUB_WORKSPACE}/rtloader/include -I${GITHUB_WORKSPACE}/rtloader/common " >> $GITHUB_ENV
- uses: actions/setup-go@v3
with:
go-version-file: ".go-version"
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build datadog agent
run: |
docker pull gcr.io/datadoghq/agent:$AGENT_VERSION
docker tag gcr.io/datadoghq/agent:$AGENT_VERSION $AGENT_IMAGE_NAME
- name: Build datadog cluster agent
run: |
docker pull gcr.io/datadoghq/cluster-agent:$AGENT_VERSION
docker tag gcr.io/datadoghq/cluster-agent:$AGENT_VERSION $CLUSTER_AGENT_IMAGE_NAME
- name: Prisma Cloud image scan agent
id: scan-agent
uses: PaloAltoNetworks/prisma-cloud-scan@v1
with:
pcc_console_url: ${{ secrets.PCC_CONSOLE_URL }}
pcc_user: ${{ secrets.PCC_USER }}
pcc_pass: ${{ secrets.PCC_PASS }}
image_name: ${{ env.AGENT_IMAGE_NAME }}
- name: Prisma Cloud image scan cluster-agent
id: scan-cluster-agent
uses: PaloAltoNetworks/prisma-cloud-scan@v1
with:
pcc_console_url: ${{ secrets.PCC_CONSOLE_URL }}
pcc_user: ${{ secrets.PCC_USER }}
pcc_pass: ${{ secrets.PCC_PASS }}
image_name: ${{ env.CLUSTER_AGENT_IMAGE_NAME }}
- name: Install Cosign
uses: sigstore/cosign-installer@main
- name: Push agent to ghcr.io
run: |
docker tag $AGENT_IMAGE_NAME ${{ env.REGISTRY }}/${{ env.AGENT_IMAGE_NAME }}
docker push ${{ env.REGISTRY }}/${{ env.AGENT_IMAGE_NAME }}
- name: Push cluster-agent to ghcr.io
run: |
docker tag $CLUSTER_AGENT_IMAGE_NAME ${{ env.REGISTRY }}/${{ env.CLUSTER_AGENT_IMAGE_NAME }}
docker push ${{ env.REGISTRY }}/${{ env.CLUSTER_AGENT_IMAGE_NAME }}
- name: Sign agent image with a key
run: |
cosign sign --key env://COSIGN_PRIVATE_KEY ${TAGS}
env:
TAGS: ghcr.io/${{ env.AGENT_IMAGE_NAME }}
COSIGN_PRIVATE_KEY: ${{secrets.COSIGN_PRIVATE_KEY}}
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}}
- name: Sign cluster-agent image with a key
run: |
cosign sign --key env://COSIGN_PRIVATE_KEY ${TAGS}
env:
TAGS: ghcr.io/${{ env.CLUSTER_AGENT_IMAGE_NAME }}
COSIGN_PRIVATE_KEY: ${{secrets.COSIGN_PRIVATE_KEY}}
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}}