From 2293e7f17811cedb1e73d13ae3ea5a3d0c09f493 Mon Sep 17 00:00:00 2001 From: SuperQ Date: Thu, 18 May 2023 15:49:56 +0200 Subject: [PATCH] skip_changelog: More fixes to version bumper * Check for remote branch before trying to build a changeset. * Fail exit if push fails. * Add pull-request permission to workflow. Signed-off-by: SuperQ --- .github/scripts/version_updater.sh | 11 +++++++++-- .github/workflows/version_bumper.yml | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/scripts/version_updater.sh b/.github/scripts/version_updater.sh index 213d2ee0..819150bd 100755 --- a/.github/scripts/version_updater.sh +++ b/.github/scripts/version_updater.sh @@ -81,6 +81,13 @@ yq eval -i ".argument_specs.main.options.${role}_version.default = \"${version}\ update_branch="autoupdate/${role}/${version}" +remote_branch="$(github_api "repos/${GIT_REPO}/branches/${update_branch}" | jq -r .name)" + +if [[ -n "${remote_branch}" ]] ; then + echo_yellow "Branch is already on remote." + exit 0 +fi + # Push new version git config user.email "${GIT_MAIL}" git config user.name "${GIT_USER}" @@ -92,8 +99,8 @@ git add \ git commit -m 'patch: :tada: automated upstream release update' echo_green "Pushing to ${update_branch} branch in ${role}" if ! git push "https://${GITHUB_TOKEN}:@github.com/${GIT_REPO}" --set-upstream "${update_branch}"; then - echo_yellow "Branch is already on remote." - exit 0 + echo_yellow "Branch push failed." + exit 1 fi if ! post_pull_request \ diff --git a/.github/workflows/version_bumper.yml b/.github/workflows/version_bumper.yml index 690fbb7f..0cdcfb95 100644 --- a/.github/workflows/version_bumper.yml +++ b/.github/workflows/version_bumper.yml @@ -27,6 +27,7 @@ jobs: needs: discover-role-repos permissions: contents: write + pull-request: write container: image: quay.io/prometheus/golang-builder:base env: