Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

handling case where scm is self hosted #257

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions stakater-create-environment/helm/templates/clustertask.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ spec:
name: CREATE_ON_CLUSTER
type: string
- default: ''
description: defaultBranch of the repository
description: This the url for api that returns commits on a pull request. If you have a self hosted scm, you will need to check its documentation for he api Url.
name: PULL_REQUEST_COMMITS_API
type: string
- description: Git PAT secret reference key
default: 'password'
name: GIT_PAT_KEY
type: string
- name: SCM
default: 'github'
description: Name of your source code management server.
type: string
steps:
- env:
- name: WORKSPACE_REPO_TOKEN_BOUND
Expand Down Expand Up @@ -80,21 +84,21 @@ spec:
echo "$FILE exists."
GIT_TOKEN=`cat $FILE`

if [[ $(params.GIT_URL) == *github.com* ]]; then
if [[ $(params.SCM) == *github* ]]; then
echo "This is a GitHub repository."
PR_FIRST_COMMIT_HASH=`curl --header "Authorization: token $GIT_TOKEN" \
$(params.PULL_REQUEST_COMMITS_API) | jq -r 'first.sha' | head -c 8`

# Check if the URL contains "gitlab.com"
elif [[ $(params.GIT_URL) == *gitlab.com* ]]; then
elif [[ $(params.SCM) == *gitlab* ]]; then
echo "This is a GitLab repository."
PR_FIRST_COMMIT_HASH=`curl --header "PRIVATE-TOKEN: $GIT_TOKEN" \
$(params.PULL_REQUEST_COMMITS_API) | jq -r '.sha // .head?.sha' | head -c 8`
fi
else
if [[ $(params.GIT_URL) == *github.com* ]]; then
if [[ $(params.SCM) == *github* ]]; then
PR_FIRST_COMMIT_HASH=`curl $(params.PULL_REQUEST_COMMITS_API) | jq -r 'first.sha' | head -c 8`
elif [[ $(params.GIT_URL) == *gitlab.com* ]]; then
elif [[ $(params.SCM) == *gitlab* ]]; then
PR_FIRST_COMMIT_HASH=`curl $(params.PULL_REQUEST_COMMITS_API) | jq -r '.sha // .head?.sha' | head -c 8`
fi
fi
Expand Down
Loading