|
6 | 6 | - cron: '0 9 * * 1' # at 9:00 UTC on Monday |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - sunset-api-version-reminder: |
| 9 | + sunset-api-version-3months-reminder: |
10 | 10 | name: Sunset APIs Reminder |
11 | 11 | runs-on: ubuntu-latest |
12 | 12 | steps: |
13 | 13 | - name: Checkout repository |
14 | 14 | uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 |
15 | | - |
16 | 15 | - name: Install Python |
17 | 16 | uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 |
18 | 17 | with: |
19 | 18 | python-version: '3.12' |
20 | | - |
21 | 19 | - name: Install FOASCLI |
22 | 20 | env: |
23 | 21 | foascli_version: ${{ vars.FOASCLI_VERSION }} |
|
27 | 25 | pushd mongodb-foas-cli_* |
28 | 26 | echo "$(pwd)/bin" >> "${GITHUB_PATH}" |
29 | 27 | popd |
30 | | -
|
31 | 28 | - name: Retrieve Sunset APIs |
32 | 29 | id: retrieve-sunset-apis |
33 | 30 | env: |
|
42 | 39 | else |
43 | 40 | # Linux date command format |
44 | 41 | three_months_date=$(date --date="3 months" +"%Y-%m-%d") |
45 | | - fi |
46 | | - |
47 | | - echo "three_months_date: ${three_months_date}" |
48 | | - |
49 | | - current_date=$(date +"%Y-%m-%d") |
50 | | - echo "current_date: ${current_date}" |
51 | | - |
52 | | - sunset_apis=$(foascli sunset ls -s "${openapi_spec_url}" --from "${current_date}" --to "${three_months_date}") |
53 | | - if [[ "${sunset_apis}" != "null" ]]; then |
54 | | - echo "API Versions that will be sunsets in the next 3 months: ${sunset_apis}" |
55 | | - |
56 | | - # We calculate the md5sum of the JSON object which will be included in the Jira ticket title. |
57 | | - # This approach ensures we create a new jira ticket only if the there is not already a ticket |
58 | | - # with the same title |
59 | | - hash_code_sunset_apis=$(echo "$sunset_apis" | jq -cS . | md5sum | awk '{print $1}') |
60 | | - echo "hash: ${hash_code_sunset_apis}" |
61 | | - echo hash_code_sunset_apis="${hash_code_sunset_apis}" >> "${GITHUB_OUTPUT:?}" |
62 | | - echo "${sunset_apis}" > sunset_apis.json |
63 | | - |
64 | | - else |
65 | | - echo "No API Versions will be sunset within the next 3 months." |
66 | | - fi |
67 | | -
|
| 42 | + fi |
| 43 | + ./.github/scripts/get_list_files_to_delete.sh "${openapi_spec_url}" "${three_months_date}" |
68 | 44 | # Create a JIRA ticket only if the there is not already a ticket with the same title |
69 | 45 | - name: Create JIRA Ticket |
70 | 46 | id: create-jira-ticket |
@@ -92,4 +68,132 @@ jobs: |
92 | 68 | message_id=$(curl -X POST -H 'Authorization: Bearer '"${SLACK_BEARER_TOKEN}" \ |
93 | 69 | -H 'Content-type: application/json' \ |
94 | 70 | --data '{"channel":"'"${SLACK_CHANNEL_ID}"'","text":"The following APIs are scheduled to be sunset in the next 3 months ('"${SLACK_APIX_2_ONCALL_USER}"'). See Jira Ticket: https://jira.mongodb.org/browse/'"${JIRA_TICKET_ID}"'","parse": "full",}' https://slack.com/api/chat.postMessage | jq '.ts') |
95 | | - echo "message_id=${message_id}"] |
| 71 | + echo "message_id=${message_id}" |
| 72 | +
|
| 73 | + sunset-api-version-1month-reminder: |
| 74 | + name: Sunset APIs Reminder |
| 75 | + runs-on: ubuntu-latest |
| 76 | + steps: |
| 77 | + - name: Checkout repository |
| 78 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 |
| 79 | + - name: Install Python |
| 80 | + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 |
| 81 | + with: |
| 82 | + python-version: '3.12' |
| 83 | + - name: Install FOASCLI |
| 84 | + env: |
| 85 | + foascli_version: ${{ vars.FOASCLI_VERSION }} |
| 86 | + run: | |
| 87 | + wget https://github.com/mongodb/openapi/releases/download/v"${foascli_version}"/mongodb-foas-cli_"${foascli_version}"_linux_x86_64.tar.gz -O foascli.tar.gz |
| 88 | + tar -xzvf foascli.tar.gz |
| 89 | + pushd mongodb-foas-cli_* |
| 90 | + echo "$(pwd)/bin" >> "${GITHUB_PATH}" |
| 91 | + popd |
| 92 | + - name: Retrieve Sunset APIs |
| 93 | + id: retrieve-sunset-apis |
| 94 | + env: |
| 95 | + openapi_spec_url: "https://raw.githubusercontent.com/mongodb/openapi/refs/heads/dev/openapi/.raw/v2.json" |
| 96 | + run: | |
| 97 | + one_month_date="" |
| 98 | + |
| 99 | + # Determine if the system is macOS or Linux |
| 100 | + if [[ "$(uname)" == "Darwin" ]]; then |
| 101 | + # macOS date command format |
| 102 | + one_month_date=$(date -v+1m +"%Y-%m-%d") |
| 103 | + else |
| 104 | + # Linux date command format |
| 105 | + one_month_date=$(date --date="1 months" +"%Y-%m-%d") |
| 106 | + fi |
| 107 | + ./.github/scripts/get_list_files_to_delete.sh "${openapi_spec_url}" "${one_month_date}" |
| 108 | + # Create a JIRA ticket only if the there is not already a ticket with the same title |
| 109 | + - name: Create JIRA Ticket |
| 110 | + id: create-jira-ticket |
| 111 | + if: steps.retrieve-sunset-apis.outputs.hash_code_sunset_apis != null |
| 112 | + env: |
| 113 | + JIRA_API_TOKEN: ${{ secrets.jira_api_token }} |
| 114 | + JIRA_TEAM_ID: ${{ vars.JIRA_TEAM_ID_APIX_2}} |
| 115 | + JIRA_TICKET_TITLE: "Some APIs are approaching their sunset date in the next month. ID: ${{steps.retrieve-sunset-apis.outputs.hash_code_sunset_apis}}" |
| 116 | + run: | |
| 117 | + sunset_apis=$(sed 's/"/\\"/g' sunset_apis.json) |
| 118 | + JIRA_TICKET_DESCRIPTION="The following APIs will be sunset in the next month. Please follow our [wiki|https://wiki.corp.mongodb.com/display/MMS/API+eXperience+Production+Checklist#APIeXperienceProductionChecklist-APISunsetActionItems]. {noformat}${sunset_apis}{noformat}" |
| 119 | + export JIRA_TICKET_DESCRIPTION |
| 120 | + .github/scripts/create_jira_ticket.sh |
| 121 | +
|
| 122 | + # Send Slack notification only if the Jira ticket was created |
| 123 | + - name: Send Slack Notification |
| 124 | + if: steps.create-jira-ticket.outputs.jira-ticket-id != null |
| 125 | + env: |
| 126 | + SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }} |
| 127 | + SLACK_BEARER_TOKEN: ${{ secrets.SLACK_BEARER_TOKEN }} |
| 128 | + SLACK_APIX_2_ONCALL_USER: ${{secrets.SLACK_APIX_2_ONCALL_USER}} |
| 129 | + JIRA_TICKET_ID: ${{ steps.create-jira-ticket.outputs.jira-ticket-id }} |
| 130 | + run: | |
| 131 | + echo "JIRA_TICKET_ID: ${JIRA_TICKET_ID}" |
| 132 | + message_id=$(curl -X POST -H 'Authorization: Bearer '"${SLACK_BEARER_TOKEN}" \ |
| 133 | + -H 'Content-type: application/json' \ |
| 134 | + --data '{"channel":"'"${SLACK_CHANNEL_ID}"'","text":"The following APIs are scheduled to be sunset in the next month ('"${SLACK_APIX_2_ONCALL_USER}"'). See Jira Ticket: https://jira.mongodb.org/browse/'"${JIRA_TICKET_ID}"'","parse": "full",}' https://slack.com/api/chat.postMessage | jq '.ts') |
| 135 | + echo "message_id=${message_id}" |
| 136 | +
|
| 137 | + sunset-api-version-1week-reminder: |
| 138 | + name: Sunset APIs Reminder |
| 139 | + runs-on: ubuntu-latest |
| 140 | + steps: |
| 141 | + - name: Checkout repository |
| 142 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 |
| 143 | + - name: Install Python |
| 144 | + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 |
| 145 | + with: |
| 146 | + python-version: '3.12' |
| 147 | + - name: Install FOASCLI |
| 148 | + env: |
| 149 | + foascli_version: ${{ vars.FOASCLI_VERSION }} |
| 150 | + run: | |
| 151 | + wget https://github.com/mongodb/openapi/releases/download/v"${foascli_version}"/mongodb-foas-cli_"${foascli_version}"_linux_x86_64.tar.gz -O foascli.tar.gz |
| 152 | + tar -xzvf foascli.tar.gz |
| 153 | + pushd mongodb-foas-cli_* |
| 154 | + echo "$(pwd)/bin" >> "${GITHUB_PATH}" |
| 155 | + popd |
| 156 | + - name: Retrieve Sunset APIs |
| 157 | + id: retrieve-sunset-apis |
| 158 | + env: |
| 159 | + openapi_spec_url: "https://raw.githubusercontent.com/mongodb/openapi/refs/heads/dev/openapi/.raw/v2.json" |
| 160 | + run: | |
| 161 | + 1_week_date="" |
| 162 | + |
| 163 | + # Determine if the system is macOS or Linux |
| 164 | + if [[ "$(uname)" == "Darwin" ]]; then |
| 165 | + # macOS date command format |
| 166 | + 1_week_date=$(date -v+1w +"%Y-%m-%d") |
| 167 | + else |
| 168 | + # Linux date command format |
| 169 | + 1_week_date=$(date --date="+1 week" +"%Y-%m-%d") |
| 170 | + fi |
| 171 | + ./.github/scripts/get_list_files_to_delete.sh "${openapi_spec_url}" "${1_week_date}" |
| 172 | + # Create a JIRA ticket only if the there is not already a ticket with the same title |
| 173 | + - name: Create JIRA Ticket |
| 174 | + id: create-jira-ticket |
| 175 | + if: steps.retrieve-sunset-apis.outputs.hash_code_sunset_apis != null |
| 176 | + env: |
| 177 | + JIRA_API_TOKEN: ${{ secrets.jira_api_token }} |
| 178 | + JIRA_TEAM_ID: ${{ vars.JIRA_TEAM_ID_APIX_2}} |
| 179 | + JIRA_TICKET_TITLE: "Some APIs are approaching their sunset date in the next week. ID: ${{steps.retrieve-sunset-apis.outputs.hash_code_sunset_apis}}" |
| 180 | + run: | |
| 181 | + sunset_apis=$(sed 's/"/\\"/g' sunset_apis.json) |
| 182 | + JIRA_TICKET_DESCRIPTION="The following APIs will be sunset in the next week. Please follow our [wiki|https://wiki.corp.mongodb.com/display/MMS/API+eXperience+Production+Checklist#APIeXperienceProductionChecklist-APISunsetActionItems]. {noformat}${sunset_apis}{noformat}" |
| 183 | + export JIRA_TICKET_DESCRIPTION |
| 184 | + .github/scripts/create_jira_ticket.sh |
| 185 | +
|
| 186 | + # Send Slack notification only if the Jira ticket was created |
| 187 | + - name: Send Slack Notification |
| 188 | + if: steps.create-jira-ticket.outputs.jira-ticket-id != null |
| 189 | + env: |
| 190 | + SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }} |
| 191 | + SLACK_BEARER_TOKEN: ${{ secrets.SLACK_BEARER_TOKEN }} |
| 192 | + SLACK_APIX_2_ONCALL_USER: ${{secrets.SLACK_APIX_2_ONCALL_USER}} |
| 193 | + JIRA_TICKET_ID: ${{ steps.create-jira-ticket.outputs.jira-ticket-id }} |
| 194 | + run: | |
| 195 | + echo "JIRA_TICKET_ID: ${JIRA_TICKET_ID}" |
| 196 | + message_id=$(curl -X POST -H 'Authorization: Bearer '"${SLACK_BEARER_TOKEN}" \ |
| 197 | + -H 'Content-type: application/json' \ |
| 198 | + --data '{"channel":"'"${SLACK_CHANNEL_ID}"'","text":"The following APIs are scheduled to be sunset in the next week ('"${SLACK_APIX_2_ONCALL_USER}"'). See Jira Ticket: https://jira.mongodb.org/browse/'"${JIRA_TICKET_ID}"'","parse": "full",}' https://slack.com/api/chat.postMessage | jq '.ts') |
| 199 | + echo "message_id=${message_id}" |
0 commit comments