Skip to content

ci: add new release version alert #32

ci: add new release version alert

ci: add new release version alert #32

name: Release Version Alert
on:
pull_request:
branches: [main]
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get PR information
id: pr-info
run: |
PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
- name: Check for __version__.py changes
id: version-changes
run: |
CHANGED_FILES=$(git --no-pager diff --name-only ${{ github.base_ref }}...${{ github.head_ref }})
if echo "$CHANGED_FILES" | grep -q '__version__.py'; then
echo "Detected __version__.py changes. Proceeding..."
else
echo "No __version__.py changes detected. Skipping workflow..."
echo "SKIP_STEPS=true" >> $GITHUB_ENV # Set an environment variable to indicate skipping steps
fi
- name: Check versions
id: check-versions
if: env.SKIP_STEPS != 'true'
run: |
CHECK_NEW_VERSION_RESPONSE=$(bash scripts/check-new-release-version.sh)
if [[ "$CHECK_NEW_VERSION_RESPONSE" == "New release version"* ]]; then
echo "Sending Slack notification..."
MESSAGE="$CHECK_NEW_VERSION_RESPONSE :rocket: Coming soon in PR: https://github.com/$GITHUB_REPOSITORY/pull/$PR_NUMBER "
echo "SLACK_MESSAGE=$MESSAGE" >> $GITHUB_ENV
else
echo "No new non-dev version found. Skipping Slack notification."
echo "SKIP_STEPS=true" >> $GITHUB_ENV # Set an environment variable to indicate skipping steps
fi
- name: Slack Notification
if: env.SKIP_STEPS != 'true'
uses: slackapi/[email protected]
with:
channel-id: 'C05RVKRFCCF'
slack-message: ${{ env.SLACK_MESSAGE }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}