Skip to content

Commit 947618f

Browse files
committed
setup publish task
1 parent a3bf7cc commit 947618f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

pipeline.gocd.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ pipelines:
3535
clean_workspace: true
3636
jobs:
3737
code:
38+
secure_variables:
39+
VAULT_TOKEN: "AES:oo4qyY+eEf1piu8V4vy4hg==:nnH/4ulwI2JgjBtBiR+LGtB+PLLWVdtsCm+CIgjNHwj+qYXlvxWbN0+RS/tSi60N"
3840
elastic_profile_id: w.c1.m1024.e5
3941
tasks:
4042
- exec:

tasks

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@
22

33
set -e
44

5+
SECRET_OPS_VERSION="0.6.2"
56
RELEASER_VERSION="2.1.0"
7+
68
RELEASER_FILE="ops/releaser-${RELEASER_VERSION}"
9+
SECRET_OPS_FILE="ops/secret-ops"
10+
SECRET_OPS_TAR_FILE="ops/secret-ops-${SECRET_OPS_VERSION}.tar.gz"
711

812
mkdir -p ops
913
if [[ ! -f $RELEASER_FILE ]];then
1014
wget --quiet -O $RELEASER_FILE https://github.com/kudulab/releaser/releases/download/${RELEASER_VERSION}/releaser
1115
fi
1216
source $RELEASER_FILE
1317

18+
if [[ ! -f $SECRET_OPS_TAR_FILE ]];then
19+
wget --quiet -O $SECRET_OPS_TAR_FILE https://github.com/kudulab/secret-ops/releases/download/${SECRET_OPS_VERSION}/secret-ops.tar.gz
20+
tar -xf $SECRET_OPS_TAR_FILE -C ops
21+
fi
22+
source $SECRET_OPS_FILE
23+
1424
command="$1"
1525
case "${command}" in
1626
set_version)
@@ -31,6 +41,8 @@ case "${command}" in
3141
;;
3242
publish)
3343
# publish the just released version
44+
GITHUB_TOKEN=$(vault read -field=token secret/gocd/github_releases)
45+
export GITHUB_TOKEN
3446
VERSION=$(releaser::get_last_git_tagged_version)
3547
releaser::prepare_github_release_bin
3648
$GHRELEASE_BIN release \
@@ -46,6 +58,12 @@ case "${command}" in
4658
--name "docker-ops" \
4759
--file src/docker-ops
4860
;;
61+
generate_vault_token)
62+
vault_token=$(vault token create -ttl=48h -policy=gocd -field token -metadata gocd_renew=true)
63+
secured_token_gocd=$(secret_ops::encrypt_with_gocd_top "${vault_token}")
64+
echo "Generated token: ${vault_token} and encrypted by GoCD server"
65+
secret_ops::insert_vault_token_gocd_yaml "${secured_token_gocd}"
66+
;;
4967
*)
5068
echo "Invalid command: '${command}'"
5169
exit 1

0 commit comments

Comments
 (0)