Skip to content

Commit

Permalink
EN-23320 - Adding Teams action in reusable workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
jsclifford committed Sep 5, 2024
1 parent 56f038e commit a796f74
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/im-reusable-finish-build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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/[email protected]
id: conclusion
Expand Down Expand Up @@ -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/[email protected]
with:
Expand All @@ -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
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/im-reusable-finish-deployment-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -140,15 +148,19 @@ 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');
printInput('MS_TEAMS_URI', '${{ secrets.MS_TEAMS_URI }}');
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/[email protected]
id: conclusion
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 }}

0 comments on commit a796f74

Please sign in to comment.