diff --git a/.github/workflows/nightly-serverless-init.yml b/.github/workflows/nightly-serverless-init.yml new file mode 100644 index 000000000..6605dd1ae --- /dev/null +++ b/.github/workflows/nightly-serverless-init.yml @@ -0,0 +1,117 @@ +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) + echo "stamp=${STAMP}" >> "$GITHUB_OUTPUT" + echo "short_sha=${SHORT_SHA}" >> "$GITHUB_OUTPUT" + echo "version=nightly-${STAMP}-${SHORT_SHA}" >> "$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 }} + 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}')"