From a796f74ece82e1c1a741d7305bba5c00d3a16745 Mon Sep 17 00:00:00 2001 From: Josh Clifford <37558619+jsclifford@users.noreply.github.com> Date: Thu, 5 Sep 2024 12:13:43 -0600 Subject: [PATCH] EN-23320 - Adding Teams action in reusable workflows --- .../im-reusable-finish-build-workflow.yml | 15 ++++++++++++++- .../im-reusable-finish-deployment-workflow.yml | 16 +++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/im-reusable-finish-build-workflow.yml b/.github/workflows/im-reusable-finish-build-workflow.yml index 0ad78d27..92c82921 100644 --- a/.github/workflows/im-reusable-finish-build-workflow.yml +++ b/.github/workflows/im-reusable-finish-build-workflow.yml @@ -66,10 +66,19 @@ on: description: Additional PR comment content aside from workflow run and next version. required: false type: string + send-teams-notification: + description: Flag indicating whether to send a notification to the team's channel. Expected `true` or `false`. + required: false + type: boolean + default: true custom-facts-for-team-channel: description: The custom facts that will be included in the post in the team's channel. By default Workflow, Run, Actor and Version are included. required: false type: string + custom-action-for-team-channel: + description: The custom action that will be included in the post in the team's channel. + required: false + type: string ms-teams-uri: description: The URI for the teams channel where a status will be posted. Either this value or the secret MS_TEAMS_URI must be provided. This input is the preferred way to provide the URI but the secret should be used instead if the value is defined as a secret. required: false @@ -117,7 +126,9 @@ jobs: printInput('is-merge-to-main', '${{ inputs.is-merge-to-main }}'); printInput('timezone', '${{ inputs.timezone }}'); printInput('ms-teams-uri', '${{ inputs.ms-teams-uri }}'); + printInput('send-teams-notification', '${{ inputs.send-teams-notification }}'); printInput('custom-facts-for-team-channel', process.env.FACTS, true); + printInput('custom-action-for-team-channel', process.env.ACTION, true); printInput('additional-pr-comment-content', process.env.ADDITIONAL_CONTENT, true); printInput('additional-conclusions', process.env.ADDITIONAL_CONCLUSIONS, true); core.endGroup(); @@ -129,6 +140,7 @@ jobs: FACTS: ${{ inputs.custom-facts-for-team-channel }} ADDITIONAL_CONTENT: ${{ inputs.additional-pr-comment-content }} ADDITIONAL_CONCLUSIONS: ${{ inputs.additional-conclusions }} + ACTION: ${{ inputs.custom-action-for-team-channel }} - uses: im-open/workflow-conclusion@v2.2 id: conclusion @@ -165,7 +177,7 @@ jobs: FACTS: ${{ inputs.custom-facts-for-team-channel }} - name: Send status to team's notification channel - if: always() + if: always() && inputs.send-teams-notification continue-on-error: true uses: im-open/post-status-to-teams-action@v1.4 with: @@ -175,6 +187,7 @@ jobs: teams-uri: ${{ inputs.ms-teams-uri || secrets.MS_TEAMS_URI }} timezone: ${{ inputs.timezone }} custom-facts: ${{ steps.team-channel-facts.outputs.facts }} + custom-actions: ${{ inputs.custom-action-for-team-channel }} - name: Construct PR Comment id: comment diff --git a/.github/workflows/im-reusable-finish-deployment-workflow.yml b/.github/workflows/im-reusable-finish-deployment-workflow.yml index 7f180a09..397d0570 100644 --- a/.github/workflows/im-reusable-finish-deployment-workflow.yml +++ b/.github/workflows/im-reusable-finish-deployment-workflow.yml @@ -86,8 +86,16 @@ on: description: The custom facts that will be included in the post in the team's channel. By default Workflow, Run, Actor and Version are included. required: false type: string + custom-actions-for-team-channel: + description: The custom actions that will be included in the post in the team's channel. + required: false + type: string custom-facts-for-deployment-notifications-channel: - description: 'The custom facts that will be included in the Deployment Notifications channel. By default Actor and Version are included.' + description: 'The custom facts that will be included in the Deployment Notifications channel.' + required: false + type: string + custome-actions-for-deployment-notifications-channel: + description: 'The custom actions that will be included in the post in the Deployment Notifications channel. By default the actions are 'View in TechHub' and 'View in GitHub'.' required: false type: string ms-teams-uri: @@ -140,7 +148,9 @@ jobs: printInput('ms-teams-uri', '${{ inputs.ms-teams-uri }}'); printInput('deploy-notifications-channel', '${{ inputs.deploy-notifications-channel }}'); printInput('custom-facts-for-team-channel', process.env.CUSTOM_FACTS_TEAMS, true); + printInput('custom-actions-for-team-channel', process.env.CUSTOM_ACTIONS_TEAMS, true); printInput('custom-facts-for-deployment-notifications-channel', process.env.CUSTOM_FACTS_DEPLOY, true); + printInput('custom-actions-for-deployment-notifications-channel', process.env.CUSTOM_ACTIONS_DEPLOY, true); core.endGroup(); core.startGroup('Reusable workflow secrets'); @@ -148,7 +158,9 @@ jobs: core.endGroup(); env: CUSTOM_FACTS_TEAMS: ${{ inputs.custom-facts-for-team-channel }} + CUSTOM_ACTIONS_TEAMS: ${{ inputs.custom-actions-for-team-channel }} CUSTOM_FACTS_DEPLOY: ${{ inputs.custom-facts-for-deployment-notifications-channel }} + CUSTOM_ACTIONS_DEPLOY: ${{ inputs.custom-actions-for-deployment-notifications-channel }} - uses: im-open/workflow-conclusion@v2.2 id: conclusion @@ -207,6 +219,7 @@ jobs: teams-uri: ${{ inputs.ms-teams-uri || secrets.MS_TEAMS_URI }} timezone: ${{ inputs.timezone }} custom-facts: ${{ steps.team-channel-facts.outputs.facts }} + custom-actions: ${{ inputs.custom-actions-for-team-channel }} - name: Determine if a post should be made in Deployment Notifications channel if: always() @@ -271,3 +284,4 @@ jobs: timezone: ${{ inputs.timezone }} include-default-facts: false # This cuts down on the message size for the prod room custom-facts: ${{ steps.deployment-channel-facts.outputs.facts }} + custom-actions: ${{ inputs.custom-actions-for-deployment-notifications-channel }}