chore: update github action and pull request template (#41)
This commit is contained in:
parent
0fe48abcfa
commit
5491e2e535
|
@ -7,5 +7,6 @@
|
||||||
- [ ] The PR title is descriptive
|
- [ ] The PR title is descriptive
|
||||||
- [ ] The commit messages are [semantic](https://www.conventionalcommits.org/)
|
- [ ] The commit messages are [semantic](https://www.conventionalcommits.org/)
|
||||||
- [ ] Necessary tests are added
|
- [ ] Necessary tests are added
|
||||||
- [ ] Performance tests checked, no obvious performance degradation
|
- [ ] Updated the release notes
|
||||||
- [ ] Necessary documents have been added if this is a new feature
|
- [ ] Necessary documents have been added if this is a new feature
|
||||||
|
- [ ] Performance tests checked, no obvious performance degradation
|
|
@ -21,23 +21,38 @@ jobs:
|
||||||
- name: Set Variables Based on Ref
|
- name: Set Variables Based on Ref
|
||||||
id: vars
|
id: vars
|
||||||
run: |
|
run: |
|
||||||
|
PRODUCT_NAME=$(basename $(pwd)) # Get the directory name as the product name
|
||||||
|
echo "PRODUCT_NAME=$PRODUCT_NAME" >> $GITHUB_ENV
|
||||||
CURRENT_REF=${GITHUB_REF##*/}
|
CURRENT_REF=${GITHUB_REF##*/}
|
||||||
|
IS_SEMVER=false
|
||||||
|
SEMVER_REGEX="^v([0-9]+)\.([0-9]+)\.([0-9]+)$"
|
||||||
|
|
||||||
if [[ "${GITHUB_REF_TYPE}" == "branch" ]]; then
|
if [[ "${GITHUB_REF_TYPE}" == "branch" ]]; then
|
||||||
if [[ "$CURRENT_REF" == "main" ]]; then
|
if [[ "$CURRENT_REF" == "main" ]]; then
|
||||||
echo "VERSION=main" >> $GITHUB_ENV
|
echo "VERSION=main" >> $GITHUB_ENV
|
||||||
echo "BRANCH=main" >> $GITHUB_ENV
|
echo "BRANCH=main" >> $GITHUB_ENV
|
||||||
else
|
elif [[ "$CURRENT_REF" =~ $SEMVER_REGEX ]]; then
|
||||||
|
IS_SEMVER=true
|
||||||
echo "VERSION=$CURRENT_REF" >> $GITHUB_ENV
|
echo "VERSION=$CURRENT_REF" >> $GITHUB_ENV
|
||||||
echo "BRANCH=$CURRENT_REF" >> $GITHUB_ENV
|
echo "BRANCH=$CURRENT_REF" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "Branch '$CURRENT_REF' is not a valid semantic version. Skipping build."
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
|
elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
|
||||||
echo "VERSION=$CURRENT_REF" >> $GITHUB_ENV
|
if [[ "$CURRENT_REF" =~ $SEMVER_REGEX ]]; then
|
||||||
echo "BRANCH=main" >> $GITHUB_ENV # Set BRANCH to 'main' for tags
|
IS_SEMVER=true
|
||||||
|
echo "VERSION=$CURRENT_REF" >> $GITHUB_ENV
|
||||||
|
echo "BRANCH=main" >> $GITHUB_ENV # Set BRANCH to 'main' for tags
|
||||||
|
else
|
||||||
|
echo "Tag '$CURRENT_REF' is not a valid semantic version. Skipping build."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Gather branches and tags, sort, remove duplicates
|
# Gather branches and tags, filter for semantic versions, sort, remove duplicates
|
||||||
VERSIONS=$(git for-each-ref refs/remotes/origin refs/tags --format="%(refname:short)" | \
|
VERSIONS=$(git for-each-ref refs/remotes/origin refs/tags --format="%(refname:short)" | \
|
||||||
grep -E "^v[0-9.]+$" | sort -Vr | uniq | tr '\n' ',' | sed 's/,$//')
|
grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$" | sort -Vr | uniq | tr '\n' ',' | sed 's/,$//')
|
||||||
echo "VERSIONS=main,$VERSIONS" >> $GITHUB_ENV
|
echo "VERSIONS=main,$VERSIONS" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Install Hugo
|
- name: Install Hugo
|
||||||
|
@ -65,7 +80,7 @@ jobs:
|
||||||
|
|
||||||
if [[ -n $(git status --porcelain) ]]; then
|
if [[ -n $(git status --porcelain) ]]; then
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Rebuild docs for version $VERSION"
|
git commit -m "Rebuild $PRODUCT_NAME docs for version $VERSION"
|
||||||
git push origin main
|
git push origin main
|
||||||
else
|
else
|
||||||
echo "No changes to commit."
|
echo "No changes to commit."
|
||||||
|
@ -93,7 +108,7 @@ jobs:
|
||||||
|
|
||||||
if [[ -n $(git status --porcelain) ]]; then
|
if [[ -n $(git status --porcelain) ]]; then
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Rebuild docs for main branch with latest version"
|
git commit -m "Rebuild $PRODUCT_NAME docs for main branch with latest version"
|
||||||
git push origin main
|
git push origin main
|
||||||
else
|
else
|
||||||
echo "No changes to commit for main."
|
echo "No changes to commit for main."
|
||||||
|
|
Loading…
Reference in New Issue