-
Notifications
You must be signed in to change notification settings - Fork 14
CLOUDP-278929: Send a remind if an API version is approching the release date #260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d829c9b
CLOUDP-278929: Send a remind if an API version is approching the rele…
andreaangiolillo e60f6df
Update upcoming_api_releases.sh
andreaangiolillo 4899703
CLOUDP-278929: Send a remind if an API version is approching the rele…
andreaangiolillo 6fd4900
Update api-versions-reminder.yml
andreaangiolillo 98ec78f
Add logic to check for a Jira ticket with the same title
andreaangiolillo 9ebf202
Update upcoming_api_releases.sh
andreaangiolillo 64a240e
fixes
andreaangiolillo fa6b290
Update .github/scripts/upcoming_api_releases.sh
andreaangiolillo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
set -eou pipefail | ||
|
||
# This script checks for upcoming API version releases within the next 3 weeks. | ||
# It performs the following steps: | ||
# 1. Fetches and parses the `versions.json` file using in the `mongodb/openapi` repository on the `dev` branch | ||
# 2. Gets the current date in seconds since epoch. | ||
# 3. Determines if the system is macOS or Linux to use the appropriate `date` command format. | ||
# 4. Iterates through each date in the `version_dates`: | ||
# a. Converts the date to seconds since epoch. | ||
# b. Calculates the difference in days between the date and the current date. | ||
# c. Checks if the date is within 3 weeks (21 days) and adds it to the list if it is. | ||
# 5. Outputs the API versions that will be released in the next 3 weeks to the GitHub Actions output variable if any are found. | ||
|
||
|
||
URL="https://raw.githubusercontent.com/mongodb/openapi/dev/openapi/v2/versions.json" | ||
|
||
# Fetch the version.json file | ||
response=$(curl -s "${URL}") | ||
|
||
# Parse the version_dates from the JSON response using jq | ||
version_dates=$(echo "${response}" | jq -r '.[]') | ||
|
||
# Initialize an empty list to store version_dates within 3 weeks | ||
version_dates_within_3_weeks=() | ||
|
||
# Get the current date in seconds since epoch | ||
current_date=$(date +%s) | ||
|
||
# Determine if the system is macOS or Linux | ||
if [[ "$(uname)" == "Darwin" ]]; then | ||
# macOS date command format | ||
date_command="date -j -f %Y-%m-%d" | ||
else | ||
# Linux date command format | ||
date_command="date -d" | ||
fi | ||
|
||
# Iterate through each date | ||
for version_date in ${version_dates}; do | ||
# Convert the date to seconds since epoch with explicit format | ||
date_in_seconds=$($date_command "${version_date}" +%s 2>/dev/null) | ||
|
||
# Calculate the difference in days between the date and the current date | ||
diff_in_days=$(( (date_in_seconds - current_date) / (60 * 60 * 24) )) | ||
|
||
# Check if the date is within 3 weeks (21 days) | ||
if [[ "${diff_in_days}" -ge 0 && "${diff_in_days}" -le 21 ]]; then | ||
# Add the date to the list if within 3 weeks | ||
version_dates_within_3_weeks+=("${date}") | ||
fi | ||
done | ||
|
||
if [[ ${#version_dates_within_3_weeks[@]} -gt 0 ]]; then | ||
echo "API Versions that will be release in the next 3 weeks: ${version_dates_within_3_weeks[*]}" | ||
echo api_versions="${version_dates_within_3_weeks[*]}" >> "${GITHUB_OUTPUT:?}" | ||
else | ||
echo "No API Versions that will be released within the next 3 weeks." | ||
fi |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: 'Send a Slack Notification for upcoming release of API versions' | ||
|
||
on: | ||
workflow_dispatch: # Allow manual triggering | ||
schedule: | ||
- cron: '0 9 * * *' # Run once a day at 09:00 UTC | ||
|
||
jobs: | ||
send-changelog-report: | ||
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@f677139bbe7f9c59b41e40162b753c062f5d49a3 | ||
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: "New 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}}" | ||
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/'"${env.JIRA_TICKET_ID}"'","parse": "full",}' https://slack.com/api/chat.postMessage | jq '.ts') | ||
echo "message_id=${message_id}" |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wondering what will be our plan long-term with .sh logic in our platform since in the past it has proven itself difficult to maintain, perharps we can add unit tests here like it was explored with the postman project? OK to make it in a follow-up PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will create a ticket to investigate how much time we might need to migrate these scripts to golang