Skip to content

ci: add new release version alert #19

ci: add new release version alert

ci: add new release version alert #19

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")
PR_HASH=$(git rev-parse HEAD)
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
echo "PR_HASH=$PR_HASH" >> $GITHUB_ENV
- name: Retrieve Messages from Cache
uses: actions/cache@v2
with:
path: $HOME/messages_cache.txt
key: messages-cache-${{ runner.os }}-${{ hashFiles('**/messages_cache.txt') }}
restore-keys: |
messages-cache-${{ runner.os }}-
- name: Check versions
id: check-versions
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
# Check for duplicates in cache
DUPLICATE_CHECK=$(grep -Fx "${MESSAGE}" $HOME/messages_cache.txt || true)
if [ -z "$DUPLICATE_CHECK" ]; then
echo "${MESSAGE}" >> $HOME/messages_cache.txt # Store the entire message in the cache
else
echo "Message already posted. Skipping duplicate Slack notification."
exit 0 # Exit without posting a message
fi
else
echo "No new non-dev version found. Skipping Slack notification."
fi
- name: Store Messages in Cache
uses: actions/cache@v2
with:
path: $HOME/messages_cache.txt
key: messages-cache-${{ runner.os }}-${{ hashFiles('**/messages_cache.txt') }}
- name: Slack Notification
if: env.SLACK_MESSAGE != ''
uses: slackapi/[email protected]
with:
channel-id: 'C05RVKRFCCF'
slack-message: ${{ env.SLACK_MESSAGE }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}