-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Validate Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
compare_tags: | ||
if: github.repository_owner == 'armadaproject' | ||
name: "Compare tags" | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- name: "Checkout" | ||
uses: "actions/checkout@v3" | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Compare tags | ||
env: | ||
ALLOWED_BRANCH: "master" | ||
run: | | ||
ref=${{ github.ref }} | ||
tag=${ref#refs/tags/} | ||
echo "Current tag: $tag" | ||
sha=${{ github.sha }} | ||
echo "Current sha: $sha" | ||
result=0 | ||
case $tag in | ||
v?*) | ||
latest_tag_commit=$(git rev-parse refs/tags/$tag^{}) | ||
git branch --contains=$sha $ALLOWED_BRANCH >> /dev/null | ||
branch_contains_commit=$? | ||
if [[ $branch_contains_commit -eq 0 && "$latest_tag_commit" == "$sha" ]]; then | ||
result=0 | ||
else | ||
result=1 | ||
fi | ||
;; | ||
*) | ||
echo "Invalid tag $tag" | ||
result=1 | ||
;; | ||
esac | ||
if [ $result -ne 0 ]; then | ||
echo "Latest tag ($tag) does not match the current commit ($sha)." | ||
echo "::error ::Invalid ref $ref $sha" | ||
exit 1 | ||
else | ||
echo "Latest tag ($tag) matches the current commit ($sha)." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters