|
| 1 | +name: Generate Schemas batch |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + api_specs_ref: |
| 7 | + description: 'Git ref or full SHA for https://github.com/Azure/azure-rest-api-specs.' |
| 8 | + required: true |
| 9 | + default: 'main' |
| 10 | + |
| 11 | +env: |
| 12 | + SUMMARY_LOG_DIR: /tmp/summary |
| 13 | + SUMMARY_LOG_PATH: /tmp/summary/summary.log |
| 14 | + SUMMARY_LOG_ARTIFACT_NAME: summary-log |
| 15 | + AUTOGENERATE_BRANCH_NAME: autogenerate |
| 16 | + MAIN_BRANCH_NAME: main |
| 17 | +jobs: |
| 18 | + batch-0: |
| 19 | + name: Update Schemas Batch 0 |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + |
| 23 | + |
| 24 | + - name: Clone azure-rest-api-specs |
| 25 | + |
| 26 | + with: |
| 27 | + repository: Azure/azure-rest-api-specs |
| 28 | + path: workflow-temp/azure-rest-api-specs |
| 29 | + ref: ${{ github.event.inputs.api_specs_ref }} |
| 30 | + |
| 31 | + - name: Install generator npm packages |
| 32 | + run: npm ci |
| 33 | + working-directory: generator |
| 34 | + |
| 35 | + - name: Create initial log description |
| 36 | + run: mkdir -p /tmp/summary |
| 37 | + |
| 38 | + - id: generate |
| 39 | + name: Run generator |
| 40 | + run: | |
| 41 | + npm run generate-all -- --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" --summary-log-path $SUMMARY_LOG_PATH --batch-count 4 --batch-index 0 |
| 42 | + working-directory: generator |
| 43 | + |
| 44 | + - name: Commit changes |
| 45 | + uses: EndBug/add-and-commit@v7 |
| 46 | + with: |
| 47 | + author_name: github-actions |
| 48 | + |
| 49 | + message: 'Autogenerate schemas batch 0' |
| 50 | + add: '*.*' |
| 51 | + |
| 52 | + - name: Upload summary log |
| 53 | + uses: actions/upload-artifact@v2 |
| 54 | + with: |
| 55 | + name: ${{ env.SUMMARY_LOG_ARTIFACT_NAME }} |
| 56 | + path: ${{ env.SUMMARY_LOG_PATH }} |
| 57 | + batch-1: |
| 58 | + needs: batch-0 |
| 59 | + name: Update Schemas Batch 1 |
| 60 | + runs-on: ubuntu-latest |
| 61 | + steps: |
| 62 | + |
| 63 | + |
| 64 | + - name: Clone azure-rest-api-specs |
| 65 | + |
| 66 | + with: |
| 67 | + repository: Azure/azure-rest-api-specs |
| 68 | + path: workflow-temp/azure-rest-api-specs |
| 69 | + ref: ${{ github.event.inputs.api_specs_ref }} |
| 70 | + |
| 71 | + - name: Install generator npm packages |
| 72 | + run: npm ci |
| 73 | + working-directory: generator |
| 74 | + |
| 75 | + - name: Download summary log artifact |
| 76 | + uses: actions/download-artifact@v2 |
| 77 | + with: |
| 78 | + name: ${{ env.SUMMARY_LOG_ARTIFACT_NAME }} |
| 79 | + path: ${{ env.SUMMARY_LOG_DIR }} |
| 80 | + |
| 81 | + - id: generate |
| 82 | + name: Run generator |
| 83 | + run: | |
| 84 | + npm run generate-all -- --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" --summary-log-path $SUMMARY_LOG_PATH --batch-count 4 --batch-index 1 |
| 85 | + working-directory: generator |
| 86 | + |
| 87 | + - name: Commit changes |
| 88 | + uses: EndBug/add-and-commit@v7 |
| 89 | + with: |
| 90 | + author_name: github-actions |
| 91 | + |
| 92 | + message: 'Autogenerate schemas batch 1' |
| 93 | + add: '*.*' |
| 94 | + |
| 95 | + - name: Upload summary log |
| 96 | + uses: actions/upload-artifact@v2 |
| 97 | + with: |
| 98 | + name: ${{ env.SUMMARY_LOG_ARTIFACT_NAME }} |
| 99 | + path: ${{ env.SUMMARY_LOG_PATH }} |
| 100 | + batch-2: |
| 101 | + needs: batch-1 |
| 102 | + name: Update Schemas Batch 2 |
| 103 | + runs-on: ubuntu-latest |
| 104 | + steps: |
| 105 | + |
| 106 | + |
| 107 | + - name: Clone azure-rest-api-specs |
| 108 | + |
| 109 | + with: |
| 110 | + repository: Azure/azure-rest-api-specs |
| 111 | + path: workflow-temp/azure-rest-api-specs |
| 112 | + ref: ${{ github.event.inputs.api_specs_ref }} |
| 113 | + |
| 114 | + - name: Install generator npm packages |
| 115 | + run: npm ci |
| 116 | + working-directory: generator |
| 117 | + |
| 118 | + - name: Download summary log artifact |
| 119 | + uses: actions/download-artifact@v2 |
| 120 | + with: |
| 121 | + name: ${{ env.SUMMARY_LOG_ARTIFACT_NAME }} |
| 122 | + path: ${{ env.SUMMARY_LOG_DIR }} |
| 123 | + |
| 124 | + - id: generate |
| 125 | + name: Run generator |
| 126 | + run: | |
| 127 | + npm run generate-all -- --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" --summary-log-path $SUMMARY_LOG_PATH --batch-count 4 --batch-index 2 |
| 128 | + working-directory: generator |
| 129 | + |
| 130 | + - name: Commit changes |
| 131 | + uses: EndBug/add-and-commit@v7 |
| 132 | + with: |
| 133 | + author_name: github-actions |
| 134 | + |
| 135 | + message: 'Autogenerate schemas batch 2' |
| 136 | + add: '*.*' |
| 137 | + |
| 138 | + - name: Upload summary log |
| 139 | + uses: actions/upload-artifact@v2 |
| 140 | + with: |
| 141 | + name: ${{ env.SUMMARY_LOG_ARTIFACT_NAME }} |
| 142 | + path: ${{ env.SUMMARY_LOG_PATH }} |
| 143 | + batch-3: |
| 144 | + needs: batch-2 |
| 145 | + name: Update Schemas Batch 3 |
| 146 | + runs-on: ubuntu-latest |
| 147 | + steps: |
| 148 | + |
| 149 | + |
| 150 | + - name: Clone azure-rest-api-specs |
| 151 | + |
| 152 | + with: |
| 153 | + repository: Azure/azure-rest-api-specs |
| 154 | + path: workflow-temp/azure-rest-api-specs |
| 155 | + ref: ${{ github.event.inputs.api_specs_ref }} |
| 156 | + |
| 157 | + - name: Install generator npm packages |
| 158 | + run: npm ci |
| 159 | + working-directory: generator |
| 160 | + |
| 161 | + - name: Download summary log artifact |
| 162 | + uses: actions/download-artifact@v2 |
| 163 | + with: |
| 164 | + name: ${{ env.SUMMARY_LOG_ARTIFACT_NAME }} |
| 165 | + path: ${{ env.SUMMARY_LOG_DIR }} |
| 166 | + |
| 167 | + - id: generate |
| 168 | + name: Run generator |
| 169 | + run: | |
| 170 | + npm run generate-all -- --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" --summary-log-path $SUMMARY_LOG_PATH --batch-count 4 --batch-index 3 |
| 171 | +
|
| 172 | + summary="$(<$SUMMARY_LOG_PATH)" |
| 173 | + summary="${summary//'%'/'%25'}" |
| 174 | + summary="${summary//$'\n'/'%0A'}" |
| 175 | + summary="${summary//$'\r'/'%0D'}" |
| 176 | + echo "::set-output name=summary::$summary" |
| 177 | + working-directory: generator |
| 178 | + |
| 179 | + - id: get_swagger_gh_uri |
| 180 | + name: Get GitHub URI for azure-rest-api-specs |
| 181 | + run: | |
| 182 | + git_sha=`git rev-parse HEAD` |
| 183 | + echo "::set-output name=gh_uri::https://github.com/Azure/azure-rest-api-specs/tree/$git_sha" |
| 184 | + working-directory: workflow-temp/azure-rest-api-specs |
| 185 | + |
| 186 | + - name: Create Pull Request |
| 187 | + uses: peter-evans/[email protected] |
| 188 | + with: |
| 189 | + committer: GitHub <[email protected]> |
| 190 | + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> |
| 191 | + signoff: false |
| 192 | + branch: ${{ env.MAIN_BRANCH_NAME }} |
| 193 | + title: | |
| 194 | + Update Generated Schemas ${{ github.event.inputs.single_path && format('(single path: {0})', github.event.inputs.single_path) || '' }} |
| 195 | + body: | |
| 196 | + Update Generated Schemas ${{ github.event.inputs.single_path && format('(single path: {0})', github.event.inputs.single_path) || '' }} |
| 197 | +
|
| 198 | + Generate schemas for ${{ steps.get_swagger_gh_uri.outputs.gh_uri }} |
| 199 | +
|
| 200 | + Summary |
| 201 | + ${{ steps.generate.outputs.summary }} |
| 202 | + commit-message: | |
| 203 | + Update Generated Schemas ${{ github.event.inputs.single_path && format('(single path: {0})', github.event.inputs.single_path) || '' }} |
| 204 | +
|
| 205 | + Generate schemas for ${{ steps.get_swagger_gh_uri.outputs.gh_uri }} |
| 206 | + labels: ${{ env.AUTOGENERATE_BRANCH_NAME }} |
| 207 | + draft: false |
0 commit comments