Skip to content

Commit

Permalink
chore(release): fetch all refs to validate commit on main
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
chris-asl committed Dec 1, 2023
1 parent 872ca9e commit 20d3bb8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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"
Expand Down

0 comments on commit 20d3bb8

Please sign in to comment.