Skip to content

Commit ba6554c

Browse files
authored
Merge pull request #277 from im-practices/EN-23320-Adding-Teams-Action
EN-23320 - Adding Teams action in reusable workflows
2 parents 56f038e + d3f1452 commit ba6554c

File tree

3 files changed

+46
-18
lines changed

3 files changed

+46
-18
lines changed

.github/workflows/im-reusable-finish-build-workflow.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,19 @@ on:
6666
description: Additional PR comment content aside from workflow run and next version.
6767
required: false
6868
type: string
69+
send-teams-notification:
70+
description: Flag indicating whether to send a notification to the team's channel. Expected `true` or `false`.
71+
required: false
72+
type: boolean
73+
default: false
6974
custom-facts-for-team-channel:
7075
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.
7176
required: false
7277
type: string
78+
custom-actions-for-team-channel:
79+
description: The custom action that will be included in the post in the team's channel.
80+
required: false
81+
type: string
7382
ms-teams-uri:
7483
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.
7584
required: false
@@ -117,7 +126,9 @@ jobs:
117126
printInput('is-merge-to-main', '${{ inputs.is-merge-to-main }}');
118127
printInput('timezone', '${{ inputs.timezone }}');
119128
printInput('ms-teams-uri', '${{ inputs.ms-teams-uri }}');
129+
printInput('send-teams-notification', '${{ inputs.send-teams-notification }}');
120130
printInput('custom-facts-for-team-channel', process.env.FACTS, true);
131+
printInput('custom-actions-for-team-channel', process.env.ACTION, true);
121132
printInput('additional-pr-comment-content', process.env.ADDITIONAL_CONTENT, true);
122133
printInput('additional-conclusions', process.env.ADDITIONAL_CONCLUSIONS, true);
123134
core.endGroup();
@@ -129,6 +140,7 @@ jobs:
129140
FACTS: ${{ inputs.custom-facts-for-team-channel }}
130141
ADDITIONAL_CONTENT: ${{ inputs.additional-pr-comment-content }}
131142
ADDITIONAL_CONCLUSIONS: ${{ inputs.additional-conclusions }}
143+
ACTION: ${{ inputs.custom-actions-for-team-channel }}
132144

133145
- uses: im-open/workflow-conclusion@v2.2
134146
id: conclusion
@@ -165,7 +177,7 @@ jobs:
165177
FACTS: ${{ inputs.custom-facts-for-team-channel }}
166178

167179
- name: Send status to team's notification channel
168-
if: always()
180+
if: always() && inputs.send-teams-notification
169181
continue-on-error: true
170182
uses: im-open/post-status-to-teams-action@v1.4
171183
with:
@@ -175,6 +187,7 @@ jobs:
175187
teams-uri: ${{ inputs.ms-teams-uri || secrets.MS_TEAMS_URI }}
176188
timezone: ${{ inputs.timezone }}
177189
custom-facts: ${{ steps.team-channel-facts.outputs.facts }}
190+
custom-actions: ${{ inputs.custom-actions-for-team-channel }}
178191

179192
- name: Construct PR Comment
180193
id: comment

.github/workflows/im-reusable-finish-deployment-workflow.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,16 @@ on:
8686
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.
8787
required: false
8888
type: string
89+
custom-actions-for-team-channel:
90+
description: The custom actions that will be included in the post in the team's channel.
91+
required: false
92+
type: string
8993
custom-facts-for-deployment-notifications-channel:
90-
description: 'The custom facts that will be included in the Deployment Notifications channel. By default Actor and Version are included.'
94+
description: 'The custom facts that will be included in the Deployment Notifications channel.'
95+
required: false
96+
type: string
97+
custom-actions-for-deployment-notifications-channel:
98+
description: "The custom actions that will be included in the post in the Deployment Notifications channel."
9199
required: false
92100
type: string
93101
ms-teams-uri:
@@ -140,15 +148,19 @@ jobs:
140148
printInput('ms-teams-uri', '${{ inputs.ms-teams-uri }}');
141149
printInput('deploy-notifications-channel', '${{ inputs.deploy-notifications-channel }}');
142150
printInput('custom-facts-for-team-channel', process.env.CUSTOM_FACTS_TEAMS, true);
151+
printInput('custom-actions-for-team-channel', process.env.CUSTOM_ACTIONS_TEAMS, true);
143152
printInput('custom-facts-for-deployment-notifications-channel', process.env.CUSTOM_FACTS_DEPLOY, true);
153+
printInput('custom-actions-for-deployment-notifications-channel', process.env.CUSTOM_ACTIONS_DEPLOY, true);
144154
core.endGroup();
145155
146156
core.startGroup('Reusable workflow secrets');
147157
printInput('MS_TEAMS_URI', '${{ secrets.MS_TEAMS_URI }}');
148158
core.endGroup();
149159
env:
150160
CUSTOM_FACTS_TEAMS: ${{ inputs.custom-facts-for-team-channel }}
161+
CUSTOM_ACTIONS_TEAMS: ${{ inputs.custom-actions-for-team-channel }}
151162
CUSTOM_FACTS_DEPLOY: ${{ inputs.custom-facts-for-deployment-notifications-channel }}
163+
CUSTOM_ACTIONS_DEPLOY: ${{ inputs.custom-actions-for-deployment-notifications-channel}}
152164

153165
- uses: im-open/workflow-conclusion@v2.2
154166
id: conclusion
@@ -207,6 +219,7 @@ jobs:
207219
teams-uri: ${{ inputs.ms-teams-uri || secrets.MS_TEAMS_URI }}
208220
timezone: ${{ inputs.timezone }}
209221
custom-facts: ${{ steps.team-channel-facts.outputs.facts }}
222+
custom-actions: ${{ inputs.custom-actions-for-team-channel }}
210223

211224
- name: Determine if a post should be made in Deployment Notifications channel
212225
if: always()
@@ -271,3 +284,4 @@ jobs:
271284
timezone: ${{ inputs.timezone }}
272285
include-default-facts: false # This cuts down on the message size for the prod room
273286
custom-facts: ${{ steps.deployment-channel-facts.outputs.facts }}
287+
custom-actions: ${{ inputs.custom-actions-for-deployment-notifications-channel }}

.github/workflows/im-reusable-setup-build-workflow.yml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,21 @@ jobs:
152152
core.info(`Is Dependabot PR: ${isDependabotPR}`);
153153
core.setOutput('IS_DEPENDABOT_PR', isDependabotPR);
154154
155+
- uses: actions/checkout@v4
156+
if: steps.set-vars.outputs.CONTINUE_WORKFLOW == 'true'
157+
with:
158+
ref: ${{ steps.set-vars.outputs.REF_TO_BUILD_AND_TAG }}
159+
fetch-depth: 0
160+
161+
- name: Calculate next version
162+
if: steps.set-vars.outputs.CONTINUE_WORKFLOW == 'true'
163+
id: version
164+
uses: im-open/git-version-lite@v3.1
165+
with:
166+
calculate-prerelease-version: ${{ steps.set-vars.outputs.IS_PRERELEASE }}
167+
branch-name: ${{ github.head_ref }} # This is only populated when the trigger is pull_request, otherwise it is empty
168+
tag-prefix: ${{ inputs.tag-prefix }}
169+
155170
- name: Construct Workflow Summary
156171
id: summary
157172
uses: actions/github-script@v7
@@ -172,7 +187,8 @@ jobs:
172187
| IS_MERGE_TO_MAIN | \`${{ steps.set-vars.outputs.IS_MERGE_TO_MAIN }}\` |
173188
| REF_TO_BUILD_AND_TAG | \`${{ steps.set-vars.outputs.REF_TO_BUILD_AND_TAG }}\` |
174189
| DIST_TAG | \`${{ steps.set-vars.outputs.DIST_TAG }}\` |
175-
| IS_DEPENDABOT_PR | \`${{ steps.actor_check.outputs.IS_DEPENDABOT_PR }}\` |`;
190+
| IS_DEPENDABOT_PR | \`${{ steps.actor_check.outputs.IS_DEPENDABOT_PR }}\` |
191+
| NEXT_VERSION | \`${{ steps.version.outputs.NEXT_VERSION }}\` |`;
176192
} else {
177193
console.log('A workflow summary was provided and will be used instead of the default value.');
178194
}
@@ -183,18 +199,3 @@ jobs:
183199
SUMMARY: ${{ inputs.workflow-summary }}
184200

185201
- run: echo '${{ steps.summary.outputs.summary }}' >> $GITHUB_STEP_SUMMARY
186-
187-
- uses: actions/checkout@v4
188-
if: steps.set-vars.outputs.CONTINUE_WORKFLOW == 'true'
189-
with:
190-
ref: ${{ steps.set-vars.outputs.REF_TO_BUILD_AND_TAG }}
191-
fetch-depth: 0
192-
193-
- name: Calculate next version
194-
if: steps.set-vars.outputs.CONTINUE_WORKFLOW == 'true'
195-
id: version
196-
uses: im-open/git-version-lite@v3.1
197-
with:
198-
calculate-prerelease-version: ${{ steps.set-vars.outputs.IS_PRERELEASE }}
199-
branch-name: ${{ github.head_ref }} # This is only populated when the trigger is pull_request, otherwise it is empty
200-
tag-prefix: ${{ inputs.tag-prefix }}

0 commit comments

Comments
 (0)