This repository has been archived by the owner on Mar 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 197
/
.gitlab-ci.yml
99 lines (90 loc) · 3.09 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
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
stages:
- initial-status
- build
- trigger
- final-status
default:
interruptible: true
image: node
tags:
- docker-prod
workflow:
rules:
- if: $CI_EXTERNAL_PULL_REQUEST_IID
- if: $CI_PIPELINE_SOURCE == "pipeline"
trigger_internal_ci:
stage: build
variables:
DOWNSTREAM_PROJECT_ID: $DOWNSTREAM_PROJECT_ID
DOWNSTREAM_PROJECT_NAME: $DOWNSTREAM_PROJECT_NAME
script:
- |
set -e
echo $CI_EXTERNAL_PULL_REQUEST_IID
if [ -z "$CI_EXTERNAL_PULL_REQUEST_IID" ]
then
echo "CI_EXTERNAL_PULL_REQUEST_IID is empty since CI is trigger from sdk"
export CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAME=$CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAME
export CI_EXTERNAL_PULL_REQUEST_IID=$EXT_PULL_REQUEST_IID
fi
export TRIGGER_BRANCH=$CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAME
#Creating a new branch
curl --request POST --header \
"PRIVATE-TOKEN: $SVC_HLS_RENDER_API" \
"${CI_SERVER_URL}/api/v4/projects/$DOWNSTREAM_PROJECT_ID/repository/branches?branch=$CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAME&ref=master" || echo "error creating branch $CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAME"
scripts/generate-config.sh
artifacts:
paths:
- generated-config.yml
pending-update-github-pipline-status:
stage: initial-status
script:
- echo $LATEST_GITHUB_COMMIT
- |
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/heremaps/harp.gl/statuses/$LATEST_GITHUB_COMMIT \
-d '{"state":"pending","context":"ci/gitlab/main.gitlab.in.here.com", "target_url":"'$CI_PIPELINE_URL'"}'
rules:
- if: $CI_PIPELINE_SOURCE == "pipeline"
when: always
- when: never
success-update-github-pipline-status:
stage: final-status
script:
- echo $LATEST_GITHUB_COMMIT
- |
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/heremaps/harp.gl/statuses/$LATEST_GITHUB_COMMIT \
-d '{"state":"success","context":"ci/gitlab/main.gitlab.in.here.com","target_url":"'$CI_PIPELINE_URL'"}'
rules:
- if: $CI_PIPELINE_SOURCE == "pipeline"
when: on_success
- when: never
failure-update-github-pipline-status:
stage: final-status
script:
- echo $LATEST_GITHUB_COMMIT
- |
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/heremaps/harp.gl/statuses/$LATEST_GITHUB_COMMIT \
-d '{"state":"failure","context":"ci/gitlab/main.gitlab.in.here.com","target_url":"'$CI_PIPELINE_URL'"}'
rules:
- if: $CI_PIPELINE_SOURCE == "pipeline"
when: on_failure
- when: never
bridge_for_bridge:
stage: trigger
trigger:
include:
- artifact: generated-config.yml
job: trigger_internal_ci
strategy: depend