Skip to content

Add workflow desc in README #1

Add workflow desc in README

Add workflow desc in README #1

name: AutoRelease
on:
push:
branches:
- main
jobs:
release:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- run: sudo apt install jq -y
- run: |
LAST_COMMIT_HASH=$(git rev-parse HEAD)
PR_INFO=$(curl -H "Authorization: Bearer ${{ secrets.PERSONAL_SECRET_TOKEN }}" \
"https://github.ncsu.edu/api/v3/repos/${{github.repository}}/commits/$LAST_COMMIT_HASH/pulls")
PR_COUNT=$(echo "$PR_INFO" | jq length)
if [ "$PR_COUNT" -gt 0 ]; then
echo "PR names associated with the commit:"
PR_NAME=$(echo "$PR_INFO" | jq -r '.[].title' | grep Release)
RELEASE_NUMBER=$(echo $PR_NAME | cut -d'-' -f2 | tr -s ' ')
echo "v$RELEASE_NUMBER"
RELEASE_TAG=$(echo "v$RELEASE_NUMBER")
curl -L \
-X POST \
-H "Authorization: Bearer ${{ secrets.PERSONAL_SECRET_TOKEN }}" \
https://github.ncsu.edu/api/v3/repos/${{github.repository}}/releases \
-d "{\"tag_name\":\"${RELEASE_TAG}\",\"target_commitish\":\"main\",\"name\":\"${RELEASE_TAG}\",\"generate_release_notes\":true}"
else
echo "No associated PRs found for the commit."
fi