-
Notifications
You must be signed in to change notification settings - Fork 20
120 lines (103 loc) · 4.36 KB
/
nightly-serverless-init.yml
File metadata and controls
120 lines (103 loc) · 4.36 KB
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
118
119
120
name: Nightly serverless-init build
on:
schedule:
# 2 AM UTC (~9-10 PM ET), daily
- cron: "0 2 * * *"
workflow_dispatch:
env:
IMAGE_NAME: datadog/datadog-lambda-extension/serverless-init
REGISTRY: ghcr.io
jobs:
build-nightly:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
strategy:
matrix:
arrays:
- { dockerFile: "Dockerfile.serverless-init.build", isAlpine: "false", tagSuffix: "" }
- { dockerFile: "Dockerfile.serverless-init.alpine.build", isAlpine: "true", tagSuffix: "-alpine" }
name: "Nightly Build (isAlpine: ${{ matrix.arrays.isAlpine }})"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: DataDog/datadog-agent
ref: main
path: datadog-agent
- name: Compute version tags
id: meta
run: |
STAMP=$(date -u +%Y%m%d)
SHORT_SHA=$(git -C datadog-agent rev-parse --short=8 HEAD)
AGENT_VERSION=$(git -C datadog-agent tag --sort=-version:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | head -1)
echo "stamp=${STAMP}" >> "$GITHUB_OUTPUT"
echo "short_sha=${SHORT_SHA}" >> "$GITHUB_OUTPUT"
echo "version=nightly-${STAMP}-${SHORT_SHA}" >> "$GITHUB_OUTPUT"
echo "agent_version=${AGENT_VERSION}" >> "$GITHUB_OUTPUT"
# Pin QEMU to a known-good version. See release-serverless-init.yml
# and test-qemu-versions.yml for context on QEMU breakage history.
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
with:
image: tonistiigi/binfmt:qemu-v10.1.3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Build binaries
working-directory: ./scripts
run: ./build_serverless_init.sh
env:
AGENT_PATH: datadog-agent
VERSION: ${{ steps.meta.outputs.version }}
AGENT_VERSION: ${{ steps.meta.outputs.agent_version }}
SERVERLESS_INIT: "true"
ALPINE: ${{ matrix.arrays.isAlpine }}
- name: Set up build directory and copy binaries
run: cp -r .layers/. ./scripts/bin/
- name: Set up tracer installation script
run: cp ./scripts/serverless_init_dotnet.sh ./scripts/bin/
- name: Login to GHCR
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
context: ./scripts
file: ./scripts/${{ matrix.arrays.dockerFile }}
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-main${{ matrix.arrays.tagSuffix }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main-${{ steps.meta.outputs.stamp }}-${{ steps.meta.outputs.short_sha }}${{ matrix.arrays.tagSuffix }}
provenance: false
platforms: linux/amd64,linux/arm64
retry:
needs: [build-nightly]
if: failure() && fromJSON(github.run_attempt) < 2
runs-on: ubuntu-22.04
permissions:
actions: write
steps:
- name: Retry failed action
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
run: gh workflow run retry-workflow.yml -F run_id=${{ github.run_id }}
notify:
needs: [build-nightly]
if: failure() && fromJSON(github.run_attempt) >= 2
runs-on: ubuntu-22.04
steps:
- name: Notify Slack
env:
SLACK_CHANNEL: "#serverless-agent"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
run: |
OPS_MESSAGE=":gh-check-failed: Nightly serverless-init build failed!
The nightly build from datadog-agent main did not succeed after retry.
See ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID} for details."
curl -H "Content-type: application/json" -X POST "$SLACK_WEBHOOK" \
-d "$(jq -n --arg channel "$SLACK_CHANNEL" --arg text "$OPS_MESSAGE" '{channel: $channel, text: $text}')"