]> git.proxmox.com Git - mirror_acme.sh.git/blame - deploy/gitlab.sh
add parked_domans
[mirror_acme.sh.git] / deploy / gitlab.sh
CommitLineData
f1b0dd78 1#!/usr/bin/env sh
d06eea53
YB
2
3# Script to deploy certificate to a Gitlab hosted page
4
5# The following variables exported from environment will be used.
6# If not set then values previously saved in domain.conf file are used.
7
8# All the variables are required
9
10# export GITLAB_TOKEN="xxxxxxx"
11# export GITLAB_PROJECT_ID=012345
12# export GITLAB_DOMAIN="mydomain.com"
13
14gitlab_deploy() {
15 _cdomain="$1"
16 _ckey="$2"
17 _ccert="$3"
18 _cca="$4"
19 _cfullchain="$5"
20
21 _debug _cdomain "$_cdomain"
22 _debug _ckey "$_ckey"
23 _debug _ccert "$_ccert"
24 _debug _cca "$_cca"
25 _debug _cfullchain "$_cfullchain"
26
27 if [ -z "$GITLAB_TOKEN" ]; then
28 if [ -z "$Le_Deploy_gitlab_token" ]; then
29 _err "GITLAB_TOKEN not defined."
30 return 1
31 fi
32 else
33 Le_Deploy_gitlab_token="$GITLAB_TOKEN"
34 _savedomainconf Le_Deploy_gitlab_token "$Le_Deploy_gitlab_token"
6d8292cd 35 fi
d06eea53
YB
36
37 if [ -z "$GITLAB_PROJECT_ID" ]; then
38 if [ -z "$Le_Deploy_gitlab_project_id" ]; then
39 _err "GITLAB_PROJECT_ID not defined."
40 return 1
41 fi
42 else
43 Le_Deploy_gitlab_project_id="$GITLAB_PROJECT_ID"
44 _savedomainconf Le_Deploy_gitlab_project_id "$Le_Deploy_gitlab_project_id"
6d8292cd 45 fi
d06eea53
YB
46
47 if [ -z "$GITLAB_DOMAIN" ]; then
48 if [ -z "$Le_Deploy_gitlab_domain" ]; then
49 _err "GITLAB_DOMAIN not defined."
50 return 1
51 fi
52 else
53 Le_Deploy_gitlab_domain="$GITLAB_DOMAIN"
54 _savedomainconf Le_Deploy_gitlab_domain "$Le_Deploy_gitlab_domain"
6d8292cd 55 fi
d06eea53 56
8d6443b2
YB
57 string_fullchain=$(_url_encode <"$_cfullchain")
58 string_key=$(_url_encode <"$_ckey")
e3c7fc80 59
c2057775 60 body="certificate=$string_fullchain&key=$string_key"
f1b0dd78 61
c2057775 62 export _H1="PRIVATE-TOKEN: $Le_Deploy_gitlab_token"
b401dbbf 63
c2057775 64 gitlab_url="https://gitlab.com/api/v4/projects/$Le_Deploy_gitlab_project_id/pages/domains/$Le_Deploy_gitlab_domain"
f1b0dd78
YB
65
66 _response=$(_post "$body" "$gitlab_url" 0 PUT | _dbase64 "multiline")
c2057775
YB
67
68 error_response="error"
f1b0dd78 69
c2057775
YB
70 if test "${_response#*$error_response}" != "$_response"; then
71 _err "Error in deploying certificate:"
72 _err "$_response"
73 return 1
74 fi
75
76 _debug response "$_response"
77 _info "Certificate successfully deployed"
78
79 return 0
d06eea53 80}