@@ -110697,6 +110697,49 @@ const missing_functionality_warning = objective =>
110697110697 `Missing ${objective} parameter will result in reduced functionality.`
110698110698 ) || {}
110699110699
110700+ const isDebugFlagEnabled = value => {
110701+ if (!value) return false
110702+
110703+ const normalizedValue = String(value).trim().toLowerCase()
110704+ return normalizedValue === '1' || normalizedValue === 'true'
110705+ }
110706+
110707+ const isDebugEnabled = () =>
110708+ isDebugFlagEnabled(process.env.RUNNER_DEBUG) ||
110709+ isDebugFlagEnabled(process.env.ACTIONS_STEP_DEBUG)
110710+
110711+ const serializeError = err => {
110712+ if (!err) return 'Unknown error'
110713+ if (err.stack) return err.stack
110714+ if (err.message) return err.message
110715+
110716+ try {
110717+ return JSON.stringify(err, null, 2)
110718+ } catch {
110719+ return String(err)
110720+ }
110721+ }
110722+
110723+ const logError = (message, err) => {
110724+ core.error(`${message}: ${err && err.message ? err.message : String(err)}`)
110725+ if (isDebugEnabled()) {
110726+ core.debug(`Error details:\n${serializeError(err)}`)
110727+ }
110728+ }
110729+
110730+ const parseRetryInput = value => {
110731+ if (!value) return 0
110732+
110733+ const retries = Number.parseInt(value, 10)
110734+ if (Number.isNaN(retries) || retries < 0) {
110735+ throw new Error(
110736+ `Invalid "retries" input: "${value}". Please provide a non-negative integer.`
110737+ )
110738+ }
110739+
110740+ return retries
110741+ }
110742+
110700110743const access_context = context_name => {
110701110744 const context = core.getInput(context_name)
110702110745 if (!context) missing_functionality_warning(context_name)
@@ -110724,6 +110767,7 @@ async function run () {
110724110767 const msteams_emails = core.getInput('msteams_emails')
110725110768 let raw = core.getInput('raw')
110726110769 const dry_run = core.getInput('dry_run')
110770+ const retries = parseRetryInput(core.getInput('retries'))
110727110771
110728110772 const overwrite = core.getInput('overwrite')
110729110773 if (overwrite) {
@@ -110743,10 +110787,15 @@ async function run () {
110743110787 title,
110744110788 actions,
110745110789 msteams_emails,
110746- dry_run
110790+ dry_run,
110791+ retries
110747110792 })}`
110748110793 )
110749110794
110795+ if (isDebugEnabled()) {
110796+ core.debug('GitHub Actions step debug logging is enabled.')
110797+ }
110798+
110750110799 const msteams = new MSTeams()
110751110800 let payload
110752110801 if (raw === '') {
@@ -110788,13 +110837,47 @@ async function run () {
110788110837 }
110789110838
110790110839 if (dry_run === '' || dry_run === 'false') {
110791- await msteams.notify(webhook_url, payload)
110792- core.info('Sent message to Microsoft Teams')
110840+ const attempts = retries + 1
110841+ let sent = false
110842+ let lastError
110843+
110844+ for (let attempt = 1; attempt <= attempts; attempt++) {
110845+ if (isDebugEnabled()) {
110846+ core.debug(`Sending notification attempt ${attempt}/${attempts}`)
110847+ }
110848+
110849+ try {
110850+ await msteams.notify(webhook_url, payload)
110851+ sent = true
110852+ core.info('Sent message to Microsoft Teams')
110853+ break
110854+ } catch (err) {
110855+ lastError = err
110856+ logError(`Notification attempt ${attempt}/${attempts} failed`, err)
110857+
110858+ if (attempt < attempts) {
110859+ core.warning(`Retrying Microsoft Teams notification (${attempt + 1}/${attempts})`)
110860+ }
110861+ }
110862+ }
110863+
110864+ if (!sent) {
110865+ const lastErrorMessage =
110866+ lastError && lastError.message
110867+ ? lastError.message
110868+ : serializeError(lastError)
110869+
110870+ throw new Error(
110871+ `Failed to send notification to Microsoft Teams after ${attempts} attempt(s): ${lastErrorMessage}`
110872+ )
110873+ }
110793110874 } else {
110794110875 core.info('Dry run - skipping notification send. Done.')
110795110876 }
110796110877 } catch (err) {
110797- core.setFailed(err.message)
110878+ logError('Action execution failed', err)
110879+ const failureMessage = err && err.message ? err.message : serializeError(err)
110880+ core.setFailed(failureMessage)
110798110881 }
110799110882}
110800110883
0 commit comments