Register API Definition to Azure API Center #2
This file contains 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: Register API Definition to Azure API Center | |
on: | |
workflow_dispatch: | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
# Please configure the environment name required in federated identity credential | |
# https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#creating-an-environment | |
environment: production | |
steps: | |
- uses: actions/checkout@v2 | |
# https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-azure | |
# https://github.com/marketplace/actions/azure-login#login-with-openid-connect-oidc-recommended | |
- name: Azure login | |
uses: azure/login@v1 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
enable-AzPSSession: true | |
# Please create following environment variables to deploy to azure resource: RESOURCE_GROUP, RESOURCE_NAME, FILE_LOCATION | |
# RESOURCE_GROUP: Azure Resource Group name, please ensure the resource group already created. | |
# RESOURCE_NAME: Azure API Center resource name, please ensure the API Center resource already created. | |
# FILE_LOCATION: API Definition file location | |
# https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository | |
- name: Deploy to API Center | |
uses: azure/CLI@v1 | |
with: | |
azcliversion: latest | |
inlineScript: | | |
az apic api register -g ${{ vars.RESOURCE_GROUP }} -s ${{ vars.RESOURCE_NAME }} --api-location ${{ vars.FILE_LOCATION }} |