Skip to content

Commit

Permalink
[CI] Use ephemeral token for git push commands (#1991)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodm authored Jul 30, 2024
1 parent 021af2e commit 70ce2ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@ if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-package" && "$BUILDKITE_STEP_KEY" =
fi

if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-package-test-with-integrations" && "$BUILDKITE_STEP_KEY" == "pr-integrations" ]]; then
# required to set the git commit information
GITHUB_USERNAME_SECRET="elasticmachine"
export GITHUB_USERNAME_SECRET=$GITHUB_USERNAME_SECRET
export GITHUB_EMAIL_SECRET="[email protected]"
# required by `gh` commands
export GITHUB_TOKEN=$VAULT_GITHUB_TOKEN
fi

Expand Down
10 changes: 4 additions & 6 deletions .buildkite/scripts/test-with-integrations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ set_git_config() {
git config user.email "${GITHUB_EMAIL_SECRET}"
}

git_push_with_auth() {
local owner="$1"
local repository="$2"
local branch="$3"
git_push() {
local branch="$1"

retry 3 git push https://${GITHUB_USERNAME_SECRET}:${GITHUB_TOKEN}@github.com/${owner}/${repository}.git "${branch}"
retry 3 git push origin "${branch}"
}

clone_repository() {
Expand Down Expand Up @@ -141,7 +139,7 @@ create_or_update_pull_request() {
update_dependency

echo "--- Pushing branch ${INTEGRATIONS_PR_BRANCH} to integrations repository..."
git_push_with_auth "${INTEGRATIONS_GITHUB_OWNER}" "${INTEGRATIONS_GITHUB_REPO_NAME}" "${INTEGRATIONS_PR_BRANCH}"
git_push "${INTEGRATIONS_PR_BRANCH}"

if [ -z "${integrations_pr_number}" ]; then
echo "--- Creating pull request :github:"
Expand Down

0 comments on commit 70ce2ee

Please sign in to comment.