Commit 8b17d015 authored by Craig Furman's avatar Craig Furman

Tweak scripts to update ops pull mirrors

* DIGITALOCEAN_ACCESS_TOKEN no longer needed
* env vars must be exported to be seen by gitlab-rails
* Nitpicky tighening of list-projects.sh
parent 4f47310a
#!/usr/bin/env bash
set -euo pipefail
# 2807845 for security-tools
for group in 2807845 gitlab-cookbooks gl-infra; do
......@@ -7,7 +8,7 @@ for group in 2807845 gitlab-cookbooks gl-infra; do
for i in $(seq 1 "$pages"); do
for p in $(curl -s "https://gitlab.com/api/v4/groups/$group/projects?private_token=$GITLAB_PRIVATE_TOKEN&page=$i" | jq -r '.[] | .path_with_namespace'); do
echo ${p}
echo "$p"
done
done
done
......
......@@ -4,7 +4,5 @@
# copy this file to ops-instance.env and source before running the scripts.
OPS_PRIVATE_TOKEN=
CI_PRIVATE_KEY=
DIGITALOCEAN_ACCESS_TOKEN=
export OPS_PRIVATE_TOKEN=
export CI_PRIVATE_KEY=
......@@ -2,9 +2,8 @@
# OPS_PRIVATE_TOKEN
# CI_PRIVATE_KEY
# DIGITALOCEAN_ACCESS_TOKEN
raise "Environment not set, aborting!" unless ENV['OPS_PRIVATE_TOKEN'] && ENV['CI_PRIVATE_KEY'] && ENV['DIGITALOCEAN_ACCESS_TOKEN']
raise "Environment not set, aborting!" unless ENV['OPS_PRIVATE_TOKEN'] && ENV['CI_PRIVATE_KEY']
u = User.find_by(username: 'ops-gitlab-net')
File.open("/tmp/projects.list").each_line do |full_path|
full_path = full_path.chomp
......@@ -26,6 +25,5 @@ File.open("/tmp/projects.list").each_line do |full_path|
p.mirror_trigger_builds = true
p.import_url = "https://ops-gitlab-net:#{ENV['OPS_PRIVATE_TOKEN']}@gitlab.com/#{full_path}"
p.variables.build(key: 'CI_PRIVATE_KEY', value: ENV['CI_PRIVATE_KEY']) unless p.variables.find_by(key: 'CI_PRIVATE_KEY')
p.variables.build(key: 'DIGITALOCEAN_ACCESS_TOKEN', value: ENV['DIGITALOCEAN_ACCESS_TOKEN']) unless p.variables.find_by(key: 'DIGITALOCEAN_ACCESS_TOKEN')
p.save
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment