-
Notifications
You must be signed in to change notification settings - Fork 8
/
.gitlab-ci.yml
99 lines (91 loc) · 3.65 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
variables:
DOCKER_REPOSITORY: mendersoftware/mender-ci-tools
stages:
- test
- build
- publish
include:
- project: 'Northern.tech/Mender/mendertesting'
file:
- '.gitlab-ci-check-commits.yml'
- '.gitlab-ci-check-license.yml'
- '.gitlab-ci-check-docker-build.yml'
- '.gitlab-ci-check-docker-release-indep.yml'
- '.gitlab-ci-github-status-updates.yml'
.trigger:update-dependencies:mender-docs-site:
inherit:
variables: false
trigger:
project: Northern.tech/Mender/mender-docs-site
branch: master
trigger:update-dependencies:mender-docs-site:tag:
# We keep this job in .pre so it can be run regardless of the rest of the pipeline failing
stage: .pre
extends: .trigger:update-dependencies:mender-docs-site
rules:
- if: $CI_COMMIT_TAG
variables:
MENDER_CI_WORKFLOWS_VERSION: "$CI_COMMIT_TAG"
trigger:update-dependencies:mender-docs-site:manual:
# For the manual run, the user needs to set MENDER_CI_WORKFLOWS_VERSION
stage: publish
extends: .trigger:update-dependencies:mender-docs-site
when: manual
variables:
MENDER_CI_WORKFLOWS_VERSION: "$MENDER_CI_WORKFLOWS_VERSION"
.update-dependencies:
# It will run either on a parent trigger or manually
stage: publish
variables:
# Variables to be set by the parent pipeline
MENDER_CLI_VERSION: ""
MENDER_ARTIFACT_VERSION: ""
MENDER_CLIENT_VERSION: ""
image: debian:11-slim
before_script:
# Install and setup hub
- apt-get update && apt-get install -qqy hub
- export GITHUB_TOKEN="$GITHUB_BOT_TOKEN_REPO_FULL"
# Prepare SSH key
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan github.com >> ~/.ssh/known_hosts
# Configure git
- git config --global user.email "[email protected]"
- git config --global user.name "Mender Test Bot"
# Prepare workspace
- hub clone mendersoftware/${CI_PROJECT_NAME} /tmp/${CI_PROJECT_NAME}
- cd /tmp/${CI_PROJECT_NAME}
- git checkout -b update-dependencies-$(date +%s)
script:
# Update dependencies
- 'changelog_entries=""'
- if [ -n "$MENDER_CLI_VERSION" ]; then
- sed -i Dockerfile -e "s/MENDER_CLI_VERSION=.*/MENDER_CLI_VERSION=$MENDER_CLI_VERSION/"
- 'changelog_entries="${changelog_entries} --message \"Changelog: Update MENDER_CLI_VERSION to $MENDER_CLI_VERSION\""'
- fi
- if [ -n "$MENDER_ARTIFACT_VERSION" ]; then
- sed -i Dockerfile -e "s/MENDER_ARTIFACT_VERSION=.*/MENDER_ARTIFACT_VERSION=$MENDER_ARTIFACT_VERSION/"
- 'changelog_entries="${changelog_entries} --message \"Changelog: MENDER_ARTIFACT_VERSION to $MENDER_ARTIFACT_VERSION\""'
- fi
- if [ -n "$MENDER_CLIENT_VERSION" ]; then
- sed -i Dockerfile -e "s/MENDER_CLIENT_VERSION=.*/MENDER_CLIENT_VERSION=$MENDER_CLIENT_VERSION/"
- 'changelog_entries="${changelog_entries} --message \"Changelog: MENDER_CLIENT_VERSION to $MENDER_CLIENT_VERSION\""'
- fi
# Create pull request
- if ! git diff-index --quiet HEAD; then
- git add Dockerfile
- 'eval git commit --signoff --message \"feat: Update dependencies\" ${changelog_entries} --message \"Ticket: None\"'
- hub pull-request --push --base mendersoftware:master --message "Update dependencies"
- fi
update-dependencies:parent:
extends: .update-dependencies
rules:
# CI_PIPELINE_SOURCE is 'pipeline' for multi-project pipelines. See:
# https://docs.gitlab.com/ee/ci/pipelines/downstream_pipelines.html#use-rules-to-control-downstream-pipeline-jobs
- if: '$CI_PIPELINE_SOURCE == "pipeline"'
update-dependencies:manual:
extends: .update-dependencies
when: manual