diff --git a/README.md b/README.md index 7b94c88..1b1dbf5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Wait for Cloudflare Pages build to finish and send Slack notification ## Usage ```yml - name: Await CF Pages and send Slack notification - uses: arddluma/cloudflare-pages-slack-notification@v2 + uses: arddluma/cloudflare-pages-slack-notification@v2.1 with: accountEmail: ${{ secrets.CF_ACCOUNT_EMAIL }} apiKey: ${{ secrets.CF_API_KEY }} @@ -32,7 +32,7 @@ jobs: - uses: actions/checkout@v2 - name: Await CF Pages and send Slack notification id: cf-pages - uses: arddluma/cloudflare-pages-slack-notification@v2 + uses: arddluma/cloudflare-pages-slack-notification@v2.1 with: accountEmail: ${{ secrets.CF_ACCOUNT_EMAIL }} apiKey: ${{ secrets.CF_API_KEY }} diff --git a/dist/action.js b/dist/action.js index 097b813..34d02e5 100644 --- a/dist/action.js +++ b/dist/action.js @@ -11397,21 +11397,16 @@ async function run() { markedAsInProgress = true; } } - if (lastStage === "build") { + if (latestStage.status === "failure") { waiting = false; - core.setFailed(`Build failed on step: ${latestStage.name}!`); - slack.send(`:x: CloudFlare Pages \`Build\` pipeline for project *${project}* \`FAILED\`! + slack.send(`:x: CloudFlare Pages \`${latestStage.name}\` pipeline for project *${project}* \`FAILED\`! Environment: *${deployment.environment}* Deployment ID: *${deployment.id}* Checkout `).then(() => { - console.log("Slack message for BUILD failed pipeline sent!"); + console.log(`Slack message for ${latestStage.name} failed pipeline sent!`); }).catch((err) => { console.error(err); }); - return; - } - if (latestStage.status === "failed") { - waiting = false; core.setFailed(`Deployment failed on step: ${latestStage.name}!`); await updateDeployment(token, deployment, "failure"); return; @@ -11435,16 +11430,6 @@ Checkout `).then(() => { - console.log("Slack message for DEPLOYMENT failed pipeline sent!"); - }).catch((err) => { - console.error(err); - }); - } if (token !== "") { await updateDeployment(token, deployment, latestStage.status === "success" ? "success" : "failure"); } diff --git a/package.json b/package.json index 3cf896e..ceec63e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cf-pages-await", - "version": "1.0.1", + "version": "2.0.1", "description": "Wait for a Cloudflare Pages build to finish and send Slack notification", "main": "index.js", "keywords": [], diff --git a/src/action.ts b/src/action.ts index 8315427..b0449a7 100644 --- a/src/action.ts +++ b/src/action.ts @@ -46,19 +46,13 @@ export default async function run() { } } - if (lastStage === 'build') { + if (latestStage.status === 'failure') { waiting = false; - core.setFailed(`Build failed on step: ${latestStage.name}!`); - slack.send(`:x: CloudFlare Pages \`Build\` pipeline for project *${project}* \`FAILED\`!\nEnvironment: *${deployment.environment}*\nDeployment ID: *${deployment.id}*\nCheckout `).then(() => { - console.log('Slack message for BUILD failed pipeline sent!'); + slack.send(`:x: CloudFlare Pages \`${latestStage.name}\` pipeline for project *${project}* \`FAILED\`!\nEnvironment: *${deployment.environment}*\nDeployment ID: *${deployment.id}*\nCheckout `).then(() => { + console.log(`Slack message for ${latestStage.name} failed pipeline sent!`); }).catch((err) => { console.error(err); }); - return; - } - - if (latestStage.status === 'failed') { - waiting = false; core.setFailed(`Deployment failed on step: ${latestStage.name}!`); await updateDeployment(token, deployment, 'failure'); return; @@ -82,13 +76,6 @@ export default async function run() { }); } - if (deployment.latest_stage.status === 'failed' && true) { - slack.send(`:x: CloudFlare Pages \`Deployment\` pipeline for project *${project}* \`FAILED\`!\nEnvironment: *${deployment.environment}*\nDeployment ID: *${deployment.id}*\nCheckout `).then(() => { - console.log('Slack message for DEPLOYMENT failed pipeline sent!'); - }).catch((err) => { - console.error(err); - }); - } // Update deployment (if enabled) if (token !== '') {