Skip to content

Commit

Permalink
update pipelines to be triggered if PR is merged to main (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahalan authored Oct 22, 2021
1 parent 83d32ac commit 6ca234c
Show file tree
Hide file tree
Showing 95 changed files with 5,424 additions and 2,409 deletions.
86 changes: 59 additions & 27 deletions .github/workflows/ms.apimanagement.service.apis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "ApiManagement: Service Apis"
name: 'ApiManagement: Service Apis'

on:
workflow_dispatch:
Expand All @@ -15,29 +15,59 @@ on:
description: 'The version to enforce if [versionOption] is set to [custom]'
required: false
default: '0.0.1'
push:
branches:
- main
paths:
- '.github/actions/templates/**'
- '.github/workflows/ms.apimanagement.service.apis.yml'
- 'arm/Microsoft.ApiManagement/serviceResources/apis/**'
- '!arm/Microsoft.ApiManagement/serviceResources/apis/readme.md'

env:
moduleName: 'apis'
modulePath: 'arm/Microsoft.ApiManagement/serviceResources/apis'
workflowPath: '.github/workflows/ms.apimanagement.service.apis.yml'
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_MGMTGROUP_ID: ${{ secrets.ARM_MGMTGROUP_ID }}

jobs:
############################
# SET INPUT PARAMETERS #
############################
job_set_workflow_param:
runs-on: ubuntu-20.04
name: 'Set input parameters to output variables'
steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: 'Set input parameters'
id: get-workflow-param
uses: ./.github/actions/templates/getWorkflowInput
with:
workflowPath: '${{ env.workflowPath}}'
outputs:
removeDeployment: ${{ steps.get-workflow-param.outputs.removeDeployment }}
versioningOption: ${{ steps.get-workflow-param.outputs.versioningOption }}
customVersion: ${{ steps.get-workflow-param.outputs.customVersion }}

##################
# UNIT TESTS #
##################
# Global tests
# ------------
job_tests_module_global:
runs-on: ubuntu-20.04
name: "Run global module tests"
name: 'Run global module tests'
steps:
- name: "Checkout"
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: "Test module"
- name: 'Test module'
uses: ./.github/actions/templates/validateModuleGeneral
with:
modulePath: '${{ env.modulePath }}'
Expand All @@ -47,13 +77,13 @@ jobs:
# ----------------
job_tests_module_global_api:
runs-on: ubuntu-20.04
name: "Run global API module tests"
name: 'Run global API module tests'
steps:
- name: "Checkout"
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: "Test module"
- name: 'Test module'
uses: ./.github/actions/templates/validateModuleApis
with:
modulePath: '${{ env.modulePath }}'
Expand All @@ -63,13 +93,13 @@ jobs:
# --------------------------------
job_tests_module_deploy_validate:
runs-on: ubuntu-20.04
name: "Run deployment validation module tests"
name: 'Run deployment validation module tests'
strategy:
fail-fast: false
matrix:
parameterFilePaths: ['parameters.json']
steps:
- name: "Checkout"
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0
Expand All @@ -78,7 +108,7 @@ jobs:
with:
# Name of variable file
variableFileName: 'variables.module' # Don't write .json here
- name: "Test module"
- name: 'Test module'
uses: ./.github/actions/templates/validateModuleDeploy
with:
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
Expand All @@ -93,17 +123,18 @@ jobs:
####################
job_deploy_module:
runs-on: ubuntu-20.04
name: "Deploy module"
name: 'Deploy module'
needs:
- job_tests_module_global
- job_tests_module_global_api
- job_tests_module_deploy_validate
- job_set_workflow_param
- job_tests_module_global
- job_tests_module_global_api
- job_tests_module_deploy_validate
strategy:
fail-fast: false
matrix:
parameterFilePaths: ['parameters.json']
steps:
- name: "Checkout"
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0
Expand All @@ -112,7 +143,7 @@ jobs:
with:
# Name of variable file
variableFileName: 'variables.module' # Don't write .json here
- name: "Deploy module"
- name: 'Deploy module'
uses: ./.github/actions/templates/deployModule
with:
moduleName: '${{ env.moduleName }}'
Expand All @@ -122,19 +153,20 @@ jobs:
resourceGroupName: '${{ env.resourceGroupName }}'
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
removeDeployment: '${{ github.event.inputs.removeDeployment }}'
removeDeployment: '${{ needs.job_set_workflow_param.outputs.removeDeployment }}'

###############
# PUBLISH #
###############
job_publish_module:
name: "Publish module"
name: 'Publish module'
if: contains(fromJson('["refs/heads/main", "refs/heads/master"]'), github.ref)
runs-on: ubuntu-20.04
needs:
- job_set_workflow_param
- job_deploy_module
steps:
- name: "Checkout"
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0
Expand All @@ -143,7 +175,7 @@ jobs:
with:
# Name of variable file
variableFileName: 'variables.module' # Don't write .json here
- name: "Publish module"
- name: 'Publish module'
uses: ./.github/actions/templates/publishModule
with:
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
Expand All @@ -152,20 +184,20 @@ jobs:
componentTemplateSpecName: '${{ env.moduleName }}'
componentTemplateSpecDescription: '${{ env.componentTemplateSpecDescription }}'
publishToTemplateSpec: '${{ env.publishToTemplateSpec }}'
versioningOption: '${{ github.event.inputs.versioningOption }}'
customVersion: '${{ github.event.inputs.customVersion }}'
versioningOption: '${{ needs.job_set_workflow_param.outputs.versioningOption }}'
customVersion: '${{ needs.job_set_workflow_param.outputs.customVersion }}'

##############
# REMOVE #
##############
job_remove_module:
runs-on: ubuntu-20.04
name: "Remove module"
if: ${{ always() && !cancelled() && github.event.inputs.removeDeployment == 'true' && (contains(needs.*.result, 'success') || contains(needs.*.result, 'failure')) }}
name: 'Remove module'
if: ${{ always() && !cancelled() && needs.job_set_workflow_param.outputs.removeDeployment == 'true' && (contains(needs.*.result, 'success') || contains(needs.*.result, 'failure')) }}
needs:
- job_deploy_module
steps:
- name: "Checkout"
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0
Expand All @@ -174,9 +206,9 @@ jobs:
with:
# Name of variable file
variableFileName: 'variables.module' # Don't write .json here
- name: "Remove module"
- name: 'Remove module'
uses: ./.github/actions/templates/removeModule
with:
moduleName: '${{ env.moduleName }}'
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
resourceGroupName: '${{ env.resourceGroupName }}'
resourceGroupName: '${{ env.resourceGroupName }}'
Loading

0 comments on commit 6ca234c

Please sign in to comment.