Send a Slack Notification for upcoming release of API versions #12
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
name: 'Send a Slack Notification for upcoming release of API versions' | |
on: | |
workflow_dispatch: # Allow manual triggering | |
schedule: | |
- cron: '0 9 * * 1-5' # Run once a day at 09:00 UTC between Monday and Friday | |
jobs: | |
send-api-version-reminder: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository (dev branch) | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | |
with: | |
sparse-checkout: | |
.github/scripts/upcoming_api_releases.sh | |
- name: Install Python | |
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b | |
with: | |
python-version: '3.12' | |
- name: Check if there are upcoming API versions releases | |
id: check-api-versions | |
run: .github/scripts/upcoming_api_releases.sh | |
# Create a JIRA ticket for the upcoming API versions only if the there is not already a ticket with the same title | |
- name: Create JIRA Ticket | |
id: create-jira-ticket | |
if: steps.check-api-versions.outputs.api_versions != null | |
env: | |
JIRA_API_TOKEN: ${{ secrets.jira_api_token }} | |
JIRA_TICKET_TITLE: "[API Platform] API Versions (${{steps.check-api-versions.outputs.api_versions}}) are about to be released" | |
JIRA_TICKET_DESCRIPTION: "The following API Versions are scheduled to be released in the next 3 weeks: ${{steps.check-api-versions.outputs.api_versions}}. Please follow https://wiki.corp.mongodb.com/display/MMS/API+eXperience+Production+Checklist#APIeXperienceProductionChecklist-APIVersionReleasechecks" | |
run: .github/scripts/create_jira_ticket.sh | |
# Send Slack notification only if the Jira ticket was created | |
- name: Send Slack Notification | |
if: steps.create-jira-ticket.outputs.jira-ticket-id != null | |
env: | |
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID_APIX_2 }} | |
SLACK_BEARER_TOKEN: ${{ secrets.SLACK_BEARER_TOKEN }} | |
API_VERSIONS: ${{ steps.check-api-versions.outputs.api_versions }} | |
JIRA_TICKET_ID: ${{ steps.create-jira-ticket.outputs.jira-ticket-id }} | |
run: | | |
message_id=$(curl -X POST -H 'Authorization: Bearer '"${SLACK_BEARER_TOKEN}" \ | |
-H 'Content-type: application/json' \ | |
--data '{"channel":"'"${SLACK_CHANNEL_ID}"'","text":"The following API Versions are scheduled to be released in the next 3 weeks: '"${API_VERSIONS}"'. Jira Ticket: https://jira.mongodb.org/browse/'"${JIRA_TICKET_ID}"'","parse": "full",}' https://slack.com/api/chat.postMessage | jq '.ts') | |
echo "message_id=${message_id}" |