Skip to content

Commit

Permalink
Enrich notification message and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
arddluma committed May 7, 2022
1 parent d7dab43 commit 075ffac
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
Binary file added .github/images/build-failed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/images/deployment-succeeded.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Wait for CF Pages
- name: Await CF Pages and send Slack notification
id: cf-pages
uses: arddluma/cf-pages-slack-notification@v2
with:
Expand All @@ -45,6 +45,16 @@ jobs:
githubToken: ${{ secrets.GITHUB_TOKEN }}
```
## Screenshots
### If build phase fails:
![Build Fails](.github/images/build-failed.png)
### If deployment phase is successful:
![Deployment Successful](.github/images/deployment-succeeded.png)
## Outputs
* `id` - Deployment ID, example: `50ff553c-da5d-4846-8188-25ae82a3bb7d`
* `environment` - Envrionment for this deployment, either `production` or `preview`
Expand Down
23 changes: 13 additions & 10 deletions dist/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -11400,9 +11400,10 @@ async function run() {
if (lastStage === "build") {
waiting = false;
core.setFailed(`Build failed on step: ${latestStage.name}!`);
slack.send(`CloudFlare Pages Build pipeline for project ${project} FAILED!
Environment: ${deployment.environment}
Deployment ID: ${deployment.id}`).then(() => {
slack.send(`:x: CloudFlare Pages \`Build\` 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!");
}).catch((err) => {
console.error(err);
Expand All @@ -11424,19 +11425,21 @@ Deployment ID: ${deployment.id}`).then(() => {
core.setOutput("alias", aliasUrl);
core.setOutput("success", deployment.latest_stage.status === "success" ? true : false);
if (deployment.latest_stage.status === "success" && true) {
slack.send(`CloudFlare Pages Depolyment pipeline for project ${project} SUCCEEDED!
Environment: ${deployment.environment}
Deployment ID: ${deployment.id}
Deployment URL: ${deployment.url}`).then(() => {
slack.send(`:white_check_mark: CloudFlare Pages \`Deployment\` pipeline for project *${project}* \`SUCCEEDED\`!
Environment: *${deployment.environment}*
Deployment ID: *${deployment.id}*
Deployment URL: ${deployment.url}
Checkout <https://dash.cloudflare.com?to=/${accountId}/pages/view/${deployment.project_name}/${deployment.id}|build logs>`).then(() => {
console.log("Slack message for DEPLOYMENT succedded pipeline sent!");
}).catch((err) => {
console.error(err);
});
}
if (deployment.latest_stage.status === "failed" && true) {
slack.send(`CloudFlare Pages Depolyment pipeline for project ${project} FAILED!
Environment: ${deployment.environment}
Deployment ID: ${deployment.id}`).then(() => {
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);
Expand Down
6 changes: 3 additions & 3 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default async function run() {
if (lastStage === 'build') {
waiting = false;
core.setFailed(`Build failed on step: ${latestStage.name}!`);
slack.send(`CloudFlare Pages Build pipeline for project ${project} FAILED!\nEnvironment: ${deployment.environment}\nDeployment ID: ${deployment.id}`).then(() => {
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!');
}).catch((err) => {
console.error(err);
Expand All @@ -75,15 +75,15 @@ export default async function run() {
core.setOutput('success', deployment.latest_stage.status === 'success' ? true : false);

if (deployment.latest_stage.status === 'success' && true) {
slack.send(`CloudFlare Pages Depolyment pipeline for project ${project} SUCCEEDED!\nEnvironment: ${deployment.environment}\nDeployment ID: ${deployment.id}\nDeployment URL: ${deployment.url}`).then(() => {
slack.send(`:white_check_mark: CloudFlare Pages \`Deployment\` pipeline for project *${project}* \`SUCCEEDED\`!\nEnvironment: *${deployment.environment}*\nDeployment ID: *${deployment.id}*\nDeployment URL: ${deployment.url}\nCheckout <https://dash.cloudflare.com?to=/${accountId}/pages/view/${deployment.project_name}/${deployment.id}|build logs>`).then(() => {
console.log('Slack message for DEPLOYMENT succedded pipeline sent!');
}).catch((err) => {
console.error(err);
});
}

if (deployment.latest_stage.status === 'failed' && true) {
slack.send(`CloudFlare Pages Depolyment pipeline for project ${project} FAILED!\nEnvironment: ${deployment.environment}\nDeployment ID: ${deployment.id}`).then(() => {
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);
Expand Down

0 comments on commit 075ffac

Please sign in to comment.