Skip to content

Commit

Permalink
ARCH-2011 - Tweak input printing/handling
Browse files Browse the repository at this point in the history
  • Loading branch information
danielle-casella-adams committed Mar 5, 2024
1 parent a32abd8 commit fb97fc7
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 80 deletions.
58 changes: 34 additions & 24 deletions .github/workflows/im-reusable-finish-build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,40 +85,50 @@ jobs:
runs-on: ${{ inputs.runs-on }}

steps:
- name: Check and print inputs
- name: Check for missing inputs
uses: actions/github-script@v7
with:
script: |
// Some teams have this as a secret and some as a var, allow both ways
// but check at least one is provided
// Some teams have these as a secret and some as a var, allow both ways but check at least one is present
const teamsUri = '${{ inputs.ms-teams-uri || secrets.MS_TEAMS_URI }}';
if (!teamsUri || teamsUri.trim().length === 0){
core.setFailed('The MS_TEAMS_URI secret or the ms-teams-uri input (preferred) must be provided.');
}
core.info('Reusable workflow inputs:');
const inputs = [
{ name: 'runs-on', value: '${{ inputs.runs-on }}'},
{ name: 'next-version', value: '${{ inputs.next-version }}'},
{ name: 'title-of-teams-post', value: '${{ inputs.title-of-teams-post }}'},
{ name: 'is-merge-to-main', value: '${{ inputs.is-merge-to-main }}'},
{ name: 'timezone', value: '${{ inputs.timezone }}'},
{ name: 'additional-conclusions', value: '${{ inputs.additional-conclusions }}'},
{ name: 'additional-pr-comment-content', value: '${{ inputs.additional-pr-comment-content }}'},
{ name: 'custom-facts-for-team-channel', value: '${{ inputs.custom-facts-for-team-channel }}'},
{ name: 'ms-teams-uri', value: '${{ inputs.ms-teams-uri }}'}
];
for (const input of inputs){
console.log(`\n\t${input.name}: '${input.value}'`);
- name: Print inputs
uses: actions/github-script@v7
with:
script: |
function printInput(inputName, inputValue, isMultilineInput){
if (!inputValue || inputValue.trim().length === 0){
core.info(`${inputName}: Not Provided`);
} else if (isMultilineInput){
console.log(`\n${inputName}:\n${inputValue}`);
}
else {
core.info(`${inputName}: ${inputValue}`);
}
}
core.info('\n\nReusable workflow secrets:');
const secrets = [
{ name: 'MS_TEAMS_URI', value: '${{ secrets.MS_TEAMS_URI }}'}
];
for (const secret of secrets){
console.log(`\n\t${secret.name}: '${secret.value}'`);
}
core.startGroup('Reusable workflow inputs');
printInput('runs-on', '${{ inputs.runs-on }}');
printInput('next-version', '${{ inputs.next-version }}');
printInput('title-of-teams-post', '${{ inputs.title-of-teams-post }}');
printInput('is-merge-to-main', '${{ inputs.is-merge-to-main }}');
printInput('timezone', '${{ inputs.timezone }}');
printInput('ms-teams-uri', '${{ inputs.ms-teams-uri }}');
printInput('custom-facts-for-team-channel', process.env.FACTS, true);
printInput('additional-pr-comment-content', process.env.ADDITIONAL_CONTENT, true);
printInput('additional-conclusions', process.env.ADDITIONAL_CONCLUSIONS, true);
core.endGroup();
core.startGroup('Reusable workflow secrets');
printInput('MS_TEAMS_URI', '${{ secrets.MS_TEAMS_URI }}');
core.endGroup();
env:
FACTS: ${{ inputs.custom-facts-for-team-channel }}
ADDITIONAL_CONTENT: ${{ inputs.additional-pr-comment-content }}
ADDITIONAL_CONCLUSIONS: ${{ inputs.additional-conclusions }}

- uses: im-open/[email protected]
id: conclusion
Expand Down
78 changes: 43 additions & 35 deletions .github/workflows/im-reusable-finish-deployment-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,11 @@ jobs:
runs-on: ${{ inputs.runs-on }}
environment: ${{ inputs.gh-secrets-environment }}
steps:
- name: Check and print inputs
- name: Check for missing inputs
uses: actions/github-script@v7
with:
script: |
// Some teams have this as a secret and some as a var, allow both ways
// but check at least one is provided
// Some teams have these as a secret and some as a var, allow both ways but check at least one is present
const teamsUri = '${{ inputs.ms-teams-uri || secrets.MS_TEAMS_URI }}';
if (!teamsUri || teamsUri.trim().length === 0){
core.setFailed('The MS_TEAMS_URI secret or the ms-teams-uri input (preferred) must be provided.');
Expand All @@ -155,40 +154,49 @@ jobs:
core.setFailed('The DEPLOY_NOTIFICATIONS_CHANNEL secret or the deploy-notifications-channel input (preferred) must be provided.');
}
core.info('Reusable workflow inputs:');
const inputs = [
{ name: 'deployment-environment', value: '${{ inputs.deployment-environment }}'},
{ name: 'gh-secrets-environment', value: '${{ inputs.gh-secrets-environment }}'},
{ name: 'release-tag', value: '${{ inputs.release-tag }}'},
{ name: 'title-of-teams-post', value: '${{ inputs.title-of-teams-post }}'},
{ name: 'runs-on', value: '${{ inputs.runs-on }}'},
{ name: 'post-status-in-deployment-notifications-channel', value: '${{ inputs.post-status-in-deployment-notifications-channel }}'},
{ name: 'timezone', value: '${{ inputs.timezone }}'},
{ name: 'deployment-board-number', value: '${{ inputs.deployment-board-number }}'},
{ name: 'deployable-type', value: '${{ inputs.deployable-type }}'},
{ name: 'deployable-label', value: '${{ inputs.deployable-label }}'},
{ name: 'enable-deployment-slot-tracking', value: '${{ inputs.enable-deployment-slot-tracking }}'},
{ name: 'slot-swapped-with-production-slot', value: '${{ inputs.slot-swapped-with-production-slot }}'},
{ name: 'target-slot', value: '${{ inputs.target-slot }}'},
{ name: 'source-slot', value: '${{ inputs.source-slot }}'},
{ name: 'instance', value: '${{ inputs.instance }}'},
{ name: 'custom-facts-for-team-channel', value: '${{ inputs.custom-facts-for-team-channel }}'},
{ name: 'custom-facts-for-deployment-notifications-channel', value: '${{ inputs.custom-facts-for-deployment-notifications-channel }}'},
{ name: 'ms-teams-uri', value: '${{ inputs.ms-teams-uri }}'},
{ name: 'deploy-notifications-channel', value: '${{ inputs.deploy-notifications-channel }}'}
];
for (const input of inputs){
console.log(`\n\t${input.name}: '${input.value}'`);
- name: Print inputs
uses: actions/github-script@v7
with:
script: |
function printInput(inputName, inputValue, isMultilineInput){
if (!inputValue || inputValue.trim().length === 0){
core.info(`${inputName}: Not Provided`);
} else if (isMultilineInput){
console.log(`\n${inputName}:\n${inputValue}`);
}
else {
core.info(`${inputName}: ${inputValue}`);
}
}
core.startGroup('Reusable workflow inputs');
printInput('deployment-environment', '${{ inputs.deployment-environment }}');
printInput('gh-secrets-environment', '${{ inputs.gh-secrets-environment }}');
printInput('release-tag', '${{ inputs.release-tag }}');
printInput('title-of-teams-post', '${{ inputs.title-of-teams-post }}');
printInput('runs-on', '${{ inputs.runs-on }}');
printInput('post-status-in-deployment-notifications-channel', '${{ inputs.post-status-in-deployment-notifications-channel }}');
printInput('timezone', '${{ inputs.timezone }}');
printInput('deployment-board-number', '${{ inputs.deployment-board-number }}');
printInput('deployable-type', '${{ inputs.deployable-type }}');
printInput('deployable-label', '${{ inputs.deployable-label }}');
printInput('enable-deployment-slot-tracking', '${{ inputs.enable-deployment-slot-tracking }}');
printInput('slot-swapped-with-production-slot', '${{ inputs.slot-swapped-with-production-slot }}');
printInput('target-slot', '${{ inputs.target-slot }}');
printInput('source-slot', '${{ inputs.source-slot }}');
printInput('instance', '${{ inputs.instance }}');
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-facts-for-deployment-notifications-channel', process.env.CUSTOM_FACTS_DEPLOY, true);
core.endGroup();
core.info('\n\nReusable workflow secrets:');
const secrets = [
{ name: 'MS_TEAMS_URI', value: '${{ secrets.MS_TEAMS_URI }}'},
{ name: 'DEPLOY_NOTIFICATIONS_CHANNEL', value: '${{ secrets.DEPLOY_NOTIFICATIONS_CHANNEL }}'}
];
for (const secret of secrets){
console.log(`\n\t${secret.name}: '${secret.value}'`);
}
core.startGroup('Reusable workflow secrets');
printInput('MS_TEAMS_URI', '${{ secrets.MS_TEAMS_URI }}');
printInput('DEPLOY_NOTIFICATIONS_CHANNEL', '${{ secrets.DEPLOY_NOTIFICATIONS_CHANNEL }}');
core.endGroup();
env:
CUSTOM_FACTS_TEAMS: ${{ inputs.custom-facts-for-team-channel }}
CUSTOM_FACTS_DEPLOY: ${{ inputs.custom-facts-for-deployment-notifications-channel }}

- uses: im-open/[email protected]
id: conclusion
Expand Down
24 changes: 15 additions & 9 deletions .github/workflows/im-reusable-setup-build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,22 @@ jobs:
uses: actions/github-script@v7
with:
script: |
core.info('Reusable workflow inputs:');
const inputs = [
{ name: 'runs-on', value: '${{ inputs.runs-on }}'},
{ name: 'default-branch', value: '${{ inputs.default-branch }}'},
{ name: 'tag-prefix', value: '${{ inputs.tag-prefix }}'},
{ name: 'workflow-summary', value: '${{ inputs.workflow-summary }}'}
];
for (const input of inputs){
console.log(`\n\t${input.name}: '${input.value}'`);
function printInput(inputName, inputValue, isMultilineInput){
if (!inputValue || inputValue.trim().length === 0){
core.info(`${inputName}: Not Provided`);
} else if (isMultilineInput){
console.log(`\n${inputName}:\n${inputValue}`);
}
else {
core.info(`${inputName}: ${inputValue}`);
}
}
printInput('runs-on', '${{ inputs.runs-on }}');
printInput('default-branch', '${{ inputs.default-branch }}');
printInput('tag-prefix', '${{ inputs.tag-prefix }}');
printInput('workflow-summary', process.env.SUMMARY, true);
env:
SUMMARY: ${{ inputs.workflow-summary }}

- name: Set default env variables
id: set-vars
Expand Down
31 changes: 19 additions & 12 deletions .github/workflows/im-reusable-setup-deployment-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,26 @@ jobs:
uses: actions/github-script@v7
with:
script: |
core.info('Reusable workflow inputs:');
const inputs = [
{ name: 'runs-on', value: '${{ inputs.runs-on }}'},
{ name: 'ref-to-deploy', value: '${{ inputs.ref-to-deploy }}'},
{ name: 'deployment-environment', value: '${{ inputs.deployment-environment }}'},
{ name: 'production-environments', value: '${{ inputs.production-environments }}'},
{ name: 'verify-release-production-ready', value: '${{ inputs.verify-release-production-ready }}'},
{ name: 'default-branch', value: '${{ inputs.default-branch }}'},
{ name: 'workflow-summary', value: '${{ inputs.workflow-summary }}'}
];
for (const input of inputs){
console.log(`\n\t${input.name}: '${input.value}'`);
function printInput(inputName, inputValue, isMultilineInput){
if (!inputValue || inputValue.trim().length === 0){
core.info(`${inputName}: Not Provided`);
} else if (isMultilineInput){
console.log(`\n${inputName}:\n${inputValue}`);
}
else {
core.info(`${inputName}: ${inputValue}`);
}
}
printInput('runs-on', '${{ inputs.runs-on }}');
printInput('ref-to-deploy', '${{ inputs.ref-to-deploy }}');
printInput('deployment-environment', '${{ inputs.deployment-environment }}');
printInput('production-environments', '${{ inputs.production-environments }}');
printInput('verify-release-production-ready', '${{ inputs.verify-release-production-ready }}');
printInput('default-branch', '${{ inputs.default-branch }}');
printInput('workflow-summary', process.env.SUMMARY, true);
env:
SUMMARY: ${{ inputs.workflow-summary }}

- name: Construct Workflow Summary
id: summary
Expand Down

0 comments on commit fb97fc7

Please sign in to comment.