| 
 | 1 | +name: 'Release OpenAPI Spec V1 for a given environment'  | 
 | 2 | +on:  | 
 | 3 | +  workflow_call:  | 
 | 4 | +    inputs:  | 
 | 5 | +      aws_default_region:  | 
 | 6 | +        description: 'AWS Default Region.'  | 
 | 7 | +        required: true  | 
 | 8 | +        type: string  | 
 | 9 | +      aws_s3_bucket:  | 
 | 10 | +        description: 'AWS S3 Bucket.'  | 
 | 11 | +        required: true  | 
 | 12 | +        type: string  | 
 | 13 | +      env:  | 
 | 14 | +        description: 'Environment to generate the OpenAPI Spec for.'  | 
 | 15 | +        required: true  | 
 | 16 | +        type: string  | 
 | 17 | +      branch:  | 
 | 18 | +        description: 'Branch to release the OpenAPI Spec to.'  | 
 | 19 | +        required: true  | 
 | 20 | +        type: string  | 
 | 21 | +    secrets: # all secrets are passed explicitly in this workflow  | 
 | 22 | +      api_bot_pat:  | 
 | 23 | +        required: true  | 
 | 24 | +      aws_access_key_id:  | 
 | 25 | +        required: true  | 
 | 26 | +      aws_secret_access_key:  | 
 | 27 | +        required: true  | 
 | 28 | +      mms_deployed_sha_url:  | 
 | 29 | +        required: true  | 
 | 30 | + | 
 | 31 | +permissions:  | 
 | 32 | +  contents: write  | 
 | 33 | +  issues: write  | 
 | 34 | + | 
 | 35 | +jobs:  | 
 | 36 | +  release-v1-oas-apis:  | 
 | 37 | +    name: Release OpenAPI Spec for V1 (DEPRECATED) APIs  | 
 | 38 | +    runs-on: ubuntu-latest  | 
 | 39 | +    steps:  | 
 | 40 | +      - name: Download v1 Spec  | 
 | 41 | +        env:  | 
 | 42 | +          AWS_DEFAULT_REGION: ${{inputs.aws_default_region}}  | 
 | 43 | +          AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}  | 
 | 44 | +          AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}  | 
 | 45 | +          S3_BUCKET: ${{ inputs.aws_s3_bucket }}  | 
 | 46 | +          MMS_DEPLOYED_SHA_URL: ${{secrets.mms_deployed_sha_url}}  | 
 | 47 | +        run: |  | 
 | 48 | +          sha=$(curl "${MMS_DEPLOYED_SHA_URL}")  | 
 | 49 | +          echo "Downloading the OpenAPI Spec for v1 with sha ${sha}"  | 
 | 50 | +          aws s3 cp "s3://${S3_BUCKET}/openapi/oas/mms-v1/${sha}.json" "v1.json"  | 
 | 51 | +      - name: Generate YAML spec  | 
 | 52 | +        run: |  | 
 | 53 | +          sudo snap install yq  | 
 | 54 | +          yq -P '.' v1.json > v1.yaml  | 
 | 55 | +      - name: Upload artifact  | 
 | 56 | +        uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882  | 
 | 57 | +        with:  | 
 | 58 | +          name: openapi-v1-${{ inputs.env }}  | 
 | 59 | +          path: |  | 
 | 60 | +            v1.json  | 
 | 61 | +            v1.yaml  | 
 | 62 | +      - name: Checkout repository  | 
 | 63 | +        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332  | 
 | 64 | +        with:  | 
 | 65 | +          ref: ${{ inputs.branch }}  | 
 | 66 | +          token: ${{secrets.api_bot_pat}}  | 
 | 67 | +      - name: Download artifact  | 
 | 68 | +        uses: actions/download-artifact@v4  | 
 | 69 | +        with:  | 
 | 70 | +          name: openapi-v1-${{ inputs.env }}  | 
 | 71 | +          github-token: ${{ secrets.api_bot_pat }}  | 
 | 72 | +          run-id: ${{ github.run_id }}  | 
 | 73 | +          path: openapi/v1-deprecated  | 
 | 74 | +      - name: Commit changes  | 
 | 75 | +        id: commit  | 
 | 76 | +        uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842  | 
 | 77 | +        env:  | 
 | 78 | +          target_env: ${{ inputs.env }}  | 
 | 79 | +          target_branch: ${{ inputs.branch }}  | 
 | 80 | +          run_id: ${{ github.run_id }}  | 
 | 81 | +        with:  | 
 | 82 | +          commit_message: "(${{env.target_env}}) Release OpenAPI Spec V1 :rocket:. See https://github.com/mongodb/openapi/actions/runs/${{env.run_id}}."  | 
 | 83 | +          commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"  | 
 | 84 | +          branch: ${{env.target_branch}}  | 
 | 85 | +          file_pattern: "openapi/v1-deprecated/*"  | 
0 commit comments