Skip to content

Commit

Permalink
feat: use local GitLab API if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
dgniewek committed Apr 3, 2023
1 parent 41a7078 commit b1bc5de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/check-gitlab-approvals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# We assume that env variables are populated correctly (according to Atlantis documentation)
# and script is executed in proper custom workflow context:
# - ATLANTIS_GITLAB_TOKEN
# - ATLANTIS_GITLAB_HOSTNAME (if private GitLab is used)
# - HEAD_REPO_OWNER
# - HEAD_REPO_NAME
# - PULL_NUM
Expand All @@ -45,6 +46,10 @@ fi

# Variable needed for `glab`
export GITLAB_TOKEN=${ATLANTIS_GITLAB_TOKEN}
if [ -v ATLANTIS_GITLAB_HOSTNAME ] && [ ! -z "$ATLANTIS_GITLAB_HOSTNAME" ]; then
# if env set and not empty set GITLAB_HOST
GITLAB_HOST="https://${ATLANTIS_GITLAB_HOSTNAME}"
fi

REPO_NAME="${HEAD_REPO_OWNER}/${HEAD_REPO_NAME}"

Expand Down
5 changes: 5 additions & 0 deletions app/pull-gitlab-variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# We assume that env variables are populated correctly (according to Atlantis documentation)
# and script is executed in proper custom workflow context:
# - ATLANTIS_GITLAB_TOKEN
# - ATLANTIS_GITLAB_HOSTNAME (if private GitLab is used)
# - HEAD_REPO_OWNER
# - HEAD_REPO_NAME
# - REPO_REL_DIR - currently the script will use GitLab's environment scope (and `*`) from a directly nested directory under `environments/`
Expand All @@ -21,6 +22,10 @@

# Variable needed for `glab`
export GITLAB_TOKEN=${ATLANTIS_GITLAB_TOKEN}
if [ -v ATLANTIS_GITLAB_HOSTNAME ] && [ ! -z "$ATLANTIS_GITLAB_HOSTNAME" ]; then
# if env set and not empty set GITLAB_HOST
GITLAB_HOST="https://${ATLANTIS_GITLAB_HOSTNAME}"
fi

ENV_SCOPE=$(echo $REPO_REL_DIR | sed -nE 's/environments\/([^/]+).*/\1/p')
: "${ENV_SCOPE:=*}"
Expand Down

0 comments on commit b1bc5de

Please sign in to comment.