From 20d3bb8755b133426ce6436e134667df06fd3701 Mon Sep 17 00:00:00 2001 From: Chris Aslanoglou Date: Fri, 1 Dec 2023 15:40:49 +0200 Subject: [PATCH] chore(release): fetch all refs to validate commit on `main` Use `fetch-depth: 0` of checkout action to fetch all refs, as per this https://github.com/actions/checkout?tab=readme-ov-file#Fetch-all-history-for-all-tags-and-branches Finally, use `git rev-parse origin/main` since we don't have a local `main` branch ref. [no-jira] --- .github/workflows/release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2b39c58..f914f8b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,8 +9,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: + # https://github.com/actions/checkout?tab=readme-ov-file#Fetch-all-history-for-all-tags-and-branches + fetch-depth: 0 ref: ${{ github.ref }} - name: Check tag name pattern follows `vX.Y.Z` @@ -23,9 +25,7 @@ jobs: - name: Issue a release only if a tag is based on a merged commit in `main` branch run: | tag_commit=$(git rev-parse ${{ github.ref }}) - - git fetch -f origin main - merged_commit=$(git rev-parse main) + merged_commit=$(git rev-parse origin/main) if git merge-base --is-ancestor $tag_commit $merged_commit; then echo "Tag is based on a merged commit in the main branch"