|
| 1 | +# Release Cleanup creates a PR to delete any autogenerated file (OAS or changelog) that is no longer needed. |
| 2 | +# This may include: |
| 3 | +# 1) OASes files of upcoming APIs that are released to a stable api. In this event, we want to keep only the stable OAS. |
| 4 | +name: 'Release Cleanup' |
| 5 | +on: |
| 6 | + workflow_call: |
| 7 | + inputs: |
| 8 | + env: |
| 9 | + description: 'Environment used for the release.' |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + branch: |
| 13 | + description: 'Branch used for the release.' |
| 14 | + required: true |
| 15 | + type: string |
| 16 | + secrets: |
| 17 | + api_bot_pat: |
| 18 | + required: true |
| 19 | +jobs: |
| 20 | + delete-upcoming-versions-with-stable: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - name: Checkout repository |
| 24 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 |
| 25 | + with: |
| 26 | + ref: ${{ inputs.branch }} |
| 27 | + token: ${{secrets.api_bot_pat}} |
| 28 | + - name: Download release scripts |
| 29 | + uses: actions/download-artifact@v4 |
| 30 | + with: |
| 31 | + name: release-scripts |
| 32 | + github-token: ${{ secrets.api_bot_pat }} |
| 33 | + run-id: ${{ github.run_id }} |
| 34 | + path: release-scripts |
| 35 | + - name: Get List of Files to Delete |
| 36 | + id: list_files_to_delete |
| 37 | + run: ./release-scripts/get_list_files_to_delete.sh |
| 38 | + - name: Delete files |
| 39 | + env: |
| 40 | + V2_OPEN_API_FILES_TO_DELETE: ${{ steps.list_files_to_delete.outputs.V2_OPEN_API_FILES_TO_DELETE }} |
| 41 | + run: | |
| 42 | + pushd openapi/v2 |
| 43 | + |
| 44 | + FILES_CHANGED=false |
| 45 | + if [ -z "${V2_OPEN_API_FILES_TO_DELETE}" ]; then |
| 46 | + echo "V2_OPEN_API_FILES_TO_DELETE is empty. No files to delete." |
| 47 | + echo "FILES_CHANGED=${FILES_CHANGED}" >> "$GITHUB_ENV" |
| 48 | + exit 0 |
| 49 | + fi |
| 50 | + for file_to_delete in ${V2_OPEN_API_FILES_TO_DELETE}; do |
| 51 | + if [ -f "${file_to_delete}" ]; then |
| 52 | + echo "Deleting file: ${file_to_delete}" |
| 53 | + FILES_CHANGED=true |
| 54 | + rm -f "${file_to_delete}" |
| 55 | + fi |
| 56 | + done |
| 57 | + echo "FILES_CHANGED=${FILES_CHANGED}" >> "$GITHUB_ENV" |
| 58 | + |
| 59 | + popd |
| 60 | + - name: Create PR |
| 61 | + uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e |
| 62 | + if: env.FILES_CHANGED == 'true' |
| 63 | + with: |
| 64 | + token: ${{ secrets.api_bot_pat }} |
| 65 | + title: "APIBot: Release Cleanup" |
| 66 | + commit-message: "release cleanup" |
| 67 | + delete-branch: true |
| 68 | + branch: release-cleanup-${{ github.run_id }} |
| 69 | + body: | |
| 70 | + > NOTE: This PR is autogenerated. |
| 71 | + > DO NOT MERGE THE PR IF YOU ARE UNSURE ABOUT THE CHANGE. |
| 72 | + |
| 73 | + # Description |
| 74 | + This PR deletes files related to an "Upcoming" api that has been released to a "Stable" API. |
| 75 | + |
| 76 | + ## Why? |
| 77 | + The MongoDB Admin API renders OpenAPI specifications and changelog files from this repository. |
| 78 | + Since this API version is now “Stable,” the files corresponding to its previous “Upcoming” state are obsolete. |
| 79 | + Deleting these files prevents the Admin API from inadvertently displaying outdated or irrelevant information from these older specifications and changelogs. |
0 commit comments