Skip to content

Commit

Permalink
🛠️: Bug fix issue with build phase
Browse files Browse the repository at this point in the history
  • Loading branch information
arddluma committed May 20, 2022
1 parent b3248ff commit 7368aae
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 37 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down
21 changes: 3 additions & 18 deletions dist/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://dash.cloudflare.com?to=/${accountId}/pages/view/${deployment.project_name}/${deployment.id}|build logs>`).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;
Expand All @@ -11435,16 +11430,6 @@ Checkout <https://dash.cloudflare.com?to=/${accountId}/pages/view/${deployment.p
console.error(err);
});
}
if (deployment.latest_stage.status === "failed" && true) {
slack.send(`:x: CloudFlare Pages \`Deployment\` pipeline for project *${project}* \`FAILED\`!
Environment: *${deployment.environment}*
Deployment ID: *${deployment.id}*
Checkout <https://dash.cloudflare.com?to=/${accountId}/pages/view/${deployment.project_name}/${deployment.id}|build logs>`).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");
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [],
Expand Down
19 changes: 3 additions & 16 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://dash.cloudflare.com?to=/${accountId}/pages/view/${deployment.project_name}/${deployment.id}|build logs>`).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 <https://dash.cloudflare.com?to=/${accountId}/pages/view/${deployment.project_name}/${deployment.id}|build logs>`).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;
Expand All @@ -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 <https://dash.cloudflare.com?to=/${accountId}/pages/view/${deployment.project_name}/${deployment.id}|build logs>`).then(() => {
console.log('Slack message for DEPLOYMENT failed pipeline sent!');
}).catch((err) => {
console.error(err);
});
}

// Update deployment (if enabled)
if (token !== '') {
Expand Down

0 comments on commit 7368aae

Please sign in to comment.