Skip to content

Update client and create Pull request #5

Update client and create Pull request

Update client and create Pull request #5

name: Update client and create Pull request
on:
workflow_dispatch:
inputs:
swagger_hub_branch:
description: "SwaggerHub Branch"
required: true
default: master
jobs:
update-client-and-create-pull-request:
runs-on: ubuntu-22.04
steps:
- name: Check workflow run ref
run: |
if [ "$RUN_REF" != "refs/heads/main" ]; then
echo Workflow should only be run on main branch. Workflow aborted.
exit 1
fi
env:
RUN_REF: ${{ github.ref }}
- uses: actions/checkout@v4
- name: Create temp directory
run: mkdir ./.temp/
- name: Download Moira OpenAPI Specification
run: wget -O ./.temp/moira-openapi-spec.yaml --header=accept:application/yaml $MOIRA_OPENAPI_SPEC_FETCH_URI/$SWAGGER_HUB_BRANCH
env:
MOIRA_OPENAPI_SPEC_FETCH_URI: ${{ vars.MOIRA_OPENAPI_SPEC_FETCH_URI }}
SWAGGER_HUB_BRANCH: ${{ github.event.inputs.swagger_hub_branch }}
- name: Setup Kiota
uses: microsoft/setup-kiota@v0.5.0
with:
version: latest
includePreRelease: "false"
- name: Setup Git config and checkout branch
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions-bot@users.noreply.github.com"
BRANCH_NAME="update-client/$(date +%s)"
git checkout -b $BRANCH_NAME
echo "BRANCH_NAME=$BRANCH_NAME" >> "$GITHUB_ENV"
- name: Update client
run: kiota update --output ./Moira.ApiClient/
- name: Commit changes
run: |
git add .
git commit --message "Update client"
- name: Push changes
run: git push --set-upstream origin $BRANCH_NAME
- name: Create Pull request
run: gh pr create -B main -H $BRANCH_NAME --title "Update client" --body "Created by GitHub Actions"
env:
GH_TOKEN: ${{ github.token }}