Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EN-23320 - Adding Teams action in reusable workflows #277

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
jsclifford marked this conversation as resolved.
Show resolved Hide resolved
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-actions-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-actions-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-actions-for-team-channel }}

- uses: im-open/workflow-conclusion@v2.2
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/post-status-to-teams-action@v1.4
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-actions-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
custom-actions-for-deployment-notifications-channel:
description: "The custom actions that will be included in the post in the Deployment Notifications channel."
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/workflow-conclusion@v2.2
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 }}
33 changes: 17 additions & 16 deletions .github/workflows/im-reusable-setup-build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,21 @@ jobs:
core.info(`Is Dependabot PR: ${isDependabotPR}`);
core.setOutput('IS_DEPENDABOT_PR', isDependabotPR);

- uses: actions/checkout@v4
if: steps.set-vars.outputs.CONTINUE_WORKFLOW == 'true'
with:
ref: ${{ steps.set-vars.outputs.REF_TO_BUILD_AND_TAG }}
fetch-depth: 0

- name: Calculate next version
if: steps.set-vars.outputs.CONTINUE_WORKFLOW == 'true'
id: version
uses: im-open/git-version-lite@v3.1
with:
calculate-prerelease-version: ${{ steps.set-vars.outputs.IS_PRERELEASE }}
branch-name: ${{ github.head_ref }} # This is only populated when the trigger is pull_request, otherwise it is empty
tag-prefix: ${{ inputs.tag-prefix }}

- name: Construct Workflow Summary
id: summary
uses: actions/github-script@v7
Expand All @@ -172,7 +187,8 @@ jobs:
| IS_MERGE_TO_MAIN | \`${{ steps.set-vars.outputs.IS_MERGE_TO_MAIN }}\` |
| REF_TO_BUILD_AND_TAG | \`${{ steps.set-vars.outputs.REF_TO_BUILD_AND_TAG }}\` |
| DIST_TAG | \`${{ steps.set-vars.outputs.DIST_TAG }}\` |
| IS_DEPENDABOT_PR | \`${{ steps.actor_check.outputs.IS_DEPENDABOT_PR }}\` |`;
| IS_DEPENDABOT_PR | \`${{ steps.actor_check.outputs.IS_DEPENDABOT_PR }}\` |
| NEXT_VERSION | \`${{ steps.version.outputs.NEXT_VERSION }}\` |`;
} else {
console.log('A workflow summary was provided and will be used instead of the default value.');
}
Expand All @@ -183,18 +199,3 @@ jobs:
SUMMARY: ${{ inputs.workflow-summary }}

- run: echo '${{ steps.summary.outputs.summary }}' >> $GITHUB_STEP_SUMMARY

- uses: actions/checkout@v4
if: steps.set-vars.outputs.CONTINUE_WORKFLOW == 'true'
with:
ref: ${{ steps.set-vars.outputs.REF_TO_BUILD_AND_TAG }}
fetch-depth: 0

- name: Calculate next version
if: steps.set-vars.outputs.CONTINUE_WORKFLOW == 'true'
id: version
uses: im-open/git-version-lite@v3.1
with:
calculate-prerelease-version: ${{ steps.set-vars.outputs.IS_PRERELEASE }}
branch-name: ${{ github.head_ref }} # This is only populated when the trigger is pull_request, otherwise it is empty
tag-prefix: ${{ inputs.tag-prefix }}