diff --git a/.github/workflows/build-docusaurus-pipeline.yml b/.github/workflows/build-docusaurus-pipeline.yml index 3fe9e14..09a8efa 100644 --- a/.github/workflows/build-docusaurus-pipeline.yml +++ b/.github/workflows/build-docusaurus-pipeline.yml @@ -74,11 +74,12 @@ jobs: container: zepben/pipeline-basic outputs: git_tag: ${{ steps.tags.outputs.git_tag }} + env: + GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} steps: - - uses: actions/checkout@v4 with: - fetch-depth: 0 + token: ${{ env.GITHUB_TOKEN }} - name: Work around git permission issue run: | @@ -88,15 +89,8 @@ jobs: - name: Delete release branch run: | - # If the `release` branch already exists, remove it - # disable error failing - set +e - res=$(git push origin -d release) - if [ $? != 0 ]; then - echo "> [!NOTE] " >> "$GITHUB_STEP_SUMMARY" - echo "> :white_check_mark: Error while deleting 'release' branch in *parse-inputs* step, but that's probably OK. If nothing else failed, you're good." >> "$GITHUB_STEP_SUMMARY" - fi - continue-on-error: true + source /scripts/common.sh + clear_release_branch shell: bash - name: Create release branch diff --git a/pipelines/basic/scripts/release-checks.sh b/pipelines/basic/scripts/release-checks.sh index ff48813..1b344d7 100755 --- a/pipelines/basic/scripts/release-checks.sh +++ b/pipelines/basic/scripts/release-checks.sh @@ -40,16 +40,8 @@ do fi done -info "Clearing the 'release' branch if it exists, ignore errors" -run git push origin -d release -# In most cases the error here means that the "release" branch doesn't exist. -# If that's not the case, one the following steps will fail, and will be handled -# manually, so we ignore the error here and only showing it. -if [ $status -ne 0 ]; then - # Show the error and continue - echo "Warning: There was an error deleting a release branch: " - cat "${output_file}" -fi +info "Clearing the 'release' branch if it exists" +clear_release_branch # Get user name if [[ -z "$BITBUCKET_STEP_TRIGGERER_UUID" ]]; then diff --git a/pipelines/scripts/common.sh b/pipelines/scripts/common.sh index 10c7a74..f26a9d9 100755 --- a/pipelines/scripts/common.sh +++ b/pipelines/scripts/common.sh @@ -182,6 +182,15 @@ tag_finalize_version() { run git push --tags } +clear_release_branch() { + info "Clearing 'release' branch" + + run git ls-remote --exit-code --heads origin release >/dev/null 2>&1 + if [[ $? == '0' ]]; then + run git push origin -d release + fi +} + check_tag_exists() { version=${1:? 'Version variable is missing.'} info "Checking remote tags if version exists..."