Update Client #48
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
| name: Update Client | |
| # Set environment variables available in all jobs and steps | |
| env: | |
| python_version: "3.9" | |
| go_module: "client" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| branch: | |
| description: | |
| "Branch to commit updated client changes to:" | |
| type: string | |
| required: true | |
| workflow_call: | |
| inputs: | |
| branch: | |
| description: | |
| "Branch to commit updated client changes to:" | |
| type: string | |
| required: true | |
| jobs: | |
| get-all-service-definition: | |
| name: Get all-service definition | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout API-Uniform-Contract repo | |
| uses: actions/checkout@v5 | |
| with: | |
| token: ${{ secrets.GIT_SECRET }} | |
| repository: Arm-Debug/API-Uniform-Contract | |
| path: API-Uniform-Contract | |
| ref: main | |
| # FIXME set to `production` | |
| - uses: actions/[email protected] | |
| with: | |
| name: all-service-flat | |
| path: API-Uniform-Contract/all/1/ | |
| update-go: | |
| name: Update Go | |
| runs-on: ubuntu-latest | |
| needs: update-client | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| # So that we have correct GIT_TOKEN to push back to branch as we need workflow permissions | |
| token: ${{ secrets.GIT_SECRET }} | |
| ref: ${{ inputs.branch || github.head_ref || github.ref }} | |
| - name: Checkout Update Go action | |
| uses: actions/checkout@v5 | |
| with: | |
| repository: Arm-Debug/update-go-action | |
| ref: refs/tags/latest | |
| token: ${{ secrets.GIT_SECRET }} | |
| persist-credentials: false | |
| path: ./.github/workflows/update-go-action | |
| - name: Update Go | |
| uses: ./.github/workflows/update-go-action | |
| with: | |
| dockerfile: Dockerfile.client | |
| branch: ${{ inputs.branch || github.head_ref || github.ref }} | |
| update-client: | |
| name: Update client | |
| runs-on: ubuntu-latest | |
| needs: get-all-service-definition | |
| steps: | |
| - name: Setup python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.python_version }} | |
| - name: Install continuous-delivery-scripts | |
| run: | | |
| pip install continuous-delivery-scripts | |
| - uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ inputs.branch || github.head_ref || github.ref }} | |
| - name: Download all-service-flat artefact | |
| uses: actions/[email protected] | |
| with: | |
| name: all-service-flat | |
| path: all-service-definition | |
| - name: Download openapi-generator | |
| run: | | |
| mkdir -p /usr/local/bin/ | |
| curl https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/bin/utils/openapi-generator-cli.sh > /usr/local/bin/openapi-generator | |
| chmod u+x /usr/local/bin/openapi-generator | |
| - name: Clean up previously generated client | |
| run: | | |
| mkdir -p ${{ env.go_module }} | |
| rm -rf ${{ env.go_module }}/* | |
| - name: Generate client | |
| run: | | |
| ls all-service-definition | |
| chmod +x ./scripts/generate-client.sh | |
| ./scripts/generate-client.sh -i all-service-definition/all-def-flat.yaml -o ${{ env.go_module }} -d | |
| - name: Generate pagination extensions | |
| run: | | |
| cd generator | |
| go mod tidy | |
| go run main.go -i ../all-service-definition/all-def-flat.yaml -o ../extensions/extension_entities.gen.go -t templates/entities.go.tmpl -g collections -c ../client | |
| go run main.go -i ../all-service-definition/all-def-flat.yaml -o ../extensions/extension_jobs.gen.go -t templates/jobs.go.tmpl -g jobs -c ../client | |
| go run main.go -i ../all-service-definition/all-def-flat.yaml -o ../extensions/extension_link_followers.gen.go -t templates/linkfollowers.go.tmpl -g links -c ../client | |
| - name: Copy extensions to client | |
| run: | | |
| if [ -d ./extensions/ ]; then | |
| cp -r extensions/. ${{ env.go_module }}/ | |
| echo "EXTENSIONS_EXISTS=true" >> $GITHUB_ENV | |
| fi | |
| ls -l ${{ env.go_module }}/* | |
| - name: Upload extensions | |
| if: ${{ env.EXTENSIONS_EXISTS == 'true' }} | |
| uses: actions/[email protected] | |
| with: | |
| name: extensions | |
| path: extensions/ | |
| retention-days: 1 | |
| - name: License files | |
| run: | | |
| cd-license-files | |
| - name: Check for client changes | |
| run: | | |
| SERVER_UPDATE="$(if [[ $(git status ${{ env.go_module }}/* --porcelain | grep -v go.mod | grep -v go.sum) ]] ; then echo '✨ New server autogenerated files' ; fi)" | |
| if [[ $SERVER_UPDATE ]] ; then echo "SERVER_UPDATE=$SERVER_UPDATE" >> $GITHUB_ENV ; fi | |
| - name: Generate News File | |
| if: env.SERVER_UPDATE != '' | |
| run: | | |
| if [[ "${{ env.SERVER_UPDATE }}" ]] ; then cd-create-news-file --type feature "Updated client due to schema changes" ; fi | |
| - name: Commit changes | |
| if: env.SERVER_UPDATE != '' | |
| uses: stefanzweifel/git-auto-commit-action@v7 | |
| with: | |
| commit_message: ":sparkles: Automatic changes -> ${{ env.SERVER_UPDATE }} [ci skip]" | |
| file_pattern: ${{ env.go_module }}/* changes/* extensions/* | |
| commit_user_name: monty-bot | |
| commit_user_email: [email protected] | |
| build-and-test: | |
| name: Build and Test | |
| needs: | |
| - update-go | |
| - update-client | |
| uses: ./.github/workflows/build-and-test.yml | |
| secrets: inherit | |
| with: | |
| branch: ${{ inputs.branch || github.head_ref || github.ref }} | |
| release: | |
| name: Release if necessary | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-and-test | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Trigger release | |
| if: contains(${{ inputs.branch || github.head_ref || github.ref }} , 'main') | |
| run: gh workflow run release.yml -f release_type=release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |