forked from DataDog/dd-trace-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
72 lines (67 loc) · 3.12 KB
/
.gitlab-ci.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
stages:
- build
- deploy
variables:
LATEST_LIBRARY_x86_64_LINUX_GNU:
value: ""
description: "Location where to download latest dd-library-php-*-x86_64-linux-gnu.tar.gz archive. Leave empty to take it from the latest released github tag."
DOWNSTREAM_REL_BRANCH:
value: "master"
description: "Run a specific datadog-reliability-env branch downstream"
FORCE_TRIGGER:
value: "false"
description: "Set to true to override rules in the reliability-env pipeline (e.g. override 'only deploy master')"
include:
remote: https://gitlab-templates.ddbuild.io/libdatadog/include/ci_authenticated_job.yml
build:
stage: build
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/base:bionic
tags: [ "runner:main", "size:large" ]
script:
- |
if [ -z "$LATEST_LIBRARY_x86_64_LINUX_GNU" ]; then
UPSTREAM_TRACER_VERSION=$(curl -L https://api.github.com/repos/DataDog/dd-trace-php/releases | grep -E '"tag_name"|"prerelease"' | paste -sd" \n" - | grep -v '"prerelease": true' | grep -Pom1 '"tag_name": "\K[^"]+')
LATEST_LIBRARY_x86_64_LINUX_GNU="https://github.com/DataDog/dd-trace-php/releases/download/${UPSTREAM_TRACER_VERSION}/dd-library-php-${UPSTREAM_TRACER_VERSION}-x86_64-linux-gnu.tar.gz"
else
UPSTREAM_TRACER_VERSION=$(echo "$LATEST_LIBRARY_x86_64_LINUX_GNU" | grep -Po '(?<=dd-library-php-).+(?=-x86_64-linux-gnu.tar.gz)')
fi
- echo "UPSTREAM_TRACER_VERSION=$(UPSTREAM_TRACER_VERSION)" >> upstream.env
- curl --fail --location --output 'dd-library-php-x86_64-linux-gnu.tar.gz' "$LATEST_LIBRARY_x86_64_LINUX_GNU"
- curl --fail --location -O "$(dirname $LATEST_LIBRARY_x86_64_LINUX_GNU)/datadog-setup.php"
- tar -cf 'datadog-setup-x86_64-linux-gnu.tar' 'datadog-setup.php' 'dd-library-php-x86_64-linux-gnu.tar.gz'
artifacts:
paths:
- 'upstream.env'
- 'datadog-setup-x86_64-linux-gnu.tar'
deploy_to_reliability_env:
stage: deploy
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
trigger:
project: DataDog/apm-reliability/datadog-reliability-env
branch: $DOWNSTREAM_REL_BRANCH
variables:
UPSTREAM_PACKAGE_JOB: build
UPSTREAM_PROJECT_ID: $CI_PROJECT_ID
UPSTREAM_PROJECT_NAME: $CI_PROJECT_NAME
UPSTREAM_PIPELINE_ID: $CI_PIPELINE_ID
UPSTREAM_BRANCH: $CI_COMMIT_REF_NAME
# COMMIT_SHA would be wrong because the artifact is not built here
# UPSTREAM_COMMIT_SHA: $CI_COMMIT_SHA
FORCE_TRIGGER: $FORCE_TRIGGER
tracer-base-image:
extends: .ci_authenticated_job
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: always
stage: deploy
script:
- echo $GH_TOKEN|docker login ghcr.io/datadog -u uploader --password-stdin
- ./tooling/ci/download-binary-php.sh dev
- docker build -t ghcr.io/datadog/dd-trace-php/dd-trace-php:latest_snapshot -f ./tooling/ci/Dockerfile .
- docker push ghcr.io/datadog/dd-trace-php/dd-trace-php:latest_snapshot
- rm -rf ./tooling/ci/binaries
- ./tooling/ci/download-binary-php.sh prod
- docker build -t ghcr.io/datadog/dd-trace-php/dd-trace-php:latest -f ./tooling/ci/Dockerfile .
- docker push ghcr.io/datadog/dd-trace-php/dd-trace-php:latest