-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
114 lines (104 loc) · 2.92 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
default:
image: docker.registry.org.il/imageroot/buildah:latest
variables:
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/openlaw-bot/${CI_COMMIT_TAG}"
stages:
- build
- release
- deploy
.container:
before_script:
- echo $CI_REGISTRY_PASSWORD | buildah login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
build-master-container:
extends: .container
stage: build
script:
- buildah build -t ${CI_REGISTRY_IMAGE}:master .
- buildah push ${CI_REGISTRY_IMAGE}:master
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
build-tagged-container:
extends: .container
stage: build
script:
- buildah build -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG} -t ${CI_REGISTRY_IMAGE}:latest .
- buildah push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
- buildah push ${CI_REGISTRY_IMAGE}:latest
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/'
build-tagged-artifact:
stage: build
image: alpine:latest
before_script:
- apk add curl
script:
- tar czf openlaw-bot.tar.gz README.md LICENSE *.pl *.pm
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file openlaw-bot.tar.gz "${PACKAGE_REGISTRY_URL}/openlaw-bot.tar.gz"'
artifacts:
paths:
- openlaw-bot.tar.gz
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/'
release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
variables:
GIT_STRATEGY: none
needs:
- build-tagged-artifact
script:
- echo 'Releasing code'
release:
name: 'OpenLaw Bot ${CI_COMMIT_TAG}'
description: 'Released version ${CI_COMMIT_TAG}'
tag_name: '${CI_COMMIT_TAG}'
ref: '${CI_COMMIT_TAG}'
assets:
links:
- name: openlaw-bot.tar.gz
filepath: /openlaw-bot.tar.gz
url: "${PACKAGE_REGISTRY_URL}/openlaw-bot.tar.gz"
link_type: package
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/'
deploy:
stage: deploy
needs:
- release
variables:
ANSIBLE_TAGS: openlaw-bot
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/'
trigger:
project: resource-il/openlaw-infra
branch: master
strategy: depend
fetch-downstream-info:
stage: deploy
needs:
- release
image: alpine:latest
variables:
GIT_STRATEGY: none
script:
- apk add -q curl jq
- OPENLAW_TOOLS_TAG_LATEST=$(curl -fsS "${CI_API_V4_URL}/projects/resource-il%2Fopenlaw-tools/repository/tags?per_page=1&search=^v" | jq -r '.[0].name')
- echo "OPENLAW_TOOLS_TAG_LATEST=${OPENLAW_TOOLS_TAG_LATEST}" | tee versions.env
artifacts:
reports:
dotenv: versions.env
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/'
update-tools:
stage: .post
needs:
- job: fetch-downstream-info
artifacts: true
variables:
OPENLAW_BOT_VERSION: ${CI_COMMIT_TAG}
trigger:
project: resource-il/openlaw-tools
branch: ${OPENLAW_TOOLS_TAG_LATEST}
strategy: depend
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/'