Skip to content

Merge pull request #13 from cmendible/main #1

Merge pull request #13 from cmendible/main

Merge pull request #13 from cmendible/main #1

name: Deploy APIs via APIOps
on:
push:
branches:
- main
- dev
paths:
- "apiops/**"
- ".github/workflows/deploy-apis-with-apiops.yaml"
- ".github/workflows/run-publisher-with-env.yaml"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
COMMIT_ID_CHOICE:
description: 'Choose "publish-all-artifacts-in-repo" only when you want to force republishing all artifacts (e.g. after build failure). Otherwise stick with the default behavior of "publish-artifacts-in-last-commit"'
required: true
type: choice
default: "publish-artifacts-in-last-commit"
options:
- "publish-artifacts-in-last-commit"
- "publish-all-artifacts-in-repo"
env:
APIS_FOLDER: apiops
jobs:
get-commit:
runs-on: ubuntu-latest
steps:
# Set the COMMIT_ID env variable
- name: Set the Commit Id
id: commit
run: |
echo "::set-output name=commit_id::${{ github.sha }}"
outputs:
commit_id: ${{ steps.commit.outputs.commit_id }}
get-apis-folder:
runs-on: ubuntu-latest
steps:
# Set the COMMIT_ID env variable
- name: Set the APIS folder Id
id: apis_folder
run: |
echo $APIS_FOLDER
outputs:
apis_folder: ${{ env.APIS_FOLDER }}
#Publish with Commit ID
Push-Changes-To-APIM-Dev-With-Commit-ID:
if: (github.event.inputs.COMMIT_ID_CHOICE == 'publish-artifacts-in-last-commit' || github.event.inputs.COMMIT_ID_CHOICE == '')
needs: [get-commit, get-apis-folder]
uses: ./.github/workflows/run-publisher-with-env.yaml
with:
API_MANAGEMENT_ENVIRONMENT: dev # change this to match the dev environment created in settings
COMMIT_ID: ${{ needs.get-commit.outputs.commit_id }}
API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH: ${{ needs.get-apis-folder.outputs.apis_folder }} # change this to the artifacts folder
secrets: inherit
#Publish without Commit ID. Publishes all artifacts that reside in the artifacts forlder
Push-Changes-To-APIM-Dev-Without-Commit-ID:
if: ( github.event.inputs.COMMIT_ID_CHOICE == 'publish-all-artifacts-in-repo' )
needs: [get-commit, get-apis-folder]
uses: ./.github/workflows/run-publisher-with-env.yaml
with:
API_MANAGEMENT_ENVIRONMENT: dev # change this to match the dev environment created in settings
API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH: ${{ needs.get-apis-folder.outputs.apis_folder }} # change this to the artifacts folder
secrets: inherit
Push-Changes-To-APIM-Prod-With-Commit-ID:
if: (github.event.inputs.COMMIT_ID_CHOICE == 'publish-artifacts-in-last-commit' || github.event.inputs.COMMIT_ID_CHOICE == '')
needs: [get-commit, get-apis-folder, Push-Changes-To-APIM-Dev-With-Commit-ID]
uses: ./.github/workflows/run-publisher-with-env.yaml
with:
API_MANAGEMENT_ENVIRONMENT: prod # change this to match the prod environment created in settings
CONFIGURATION_YAML_PATH: configuration.prod.yaml # make sure the file is available at the root
API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH: ${{ needs.get-apis-folder.outputs.apis_folder }} # change this to the artifacts folder
COMMIT_ID: ${{ needs.get-commit.outputs.commit_id }}
secrets: inherit
Push-Changes-To-APIM-Prod-Without-Commit-ID:
if: ( github.event.inputs.COMMIT_ID_CHOICE == 'publish-all-artifacts-in-repo' )
needs: [get-commit, get-apis-folder, Push-Changes-To-APIM-Dev-Without-Commit-ID]
uses: ./.github/workflows/run-publisher-with-env.yaml
with:
API_MANAGEMENT_ENVIRONMENT: prod # change this to match the prod environment created in settings
CONFIGURATION_YAML_PATH: configuration.prod.yaml # make sure the file is available at the root
API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH: ${{ needs.get-apis-folder.outputs.apis_folder }} # change this to the artifacts folder
secrets: inherit