Skip to content

chore: updated tutorial workflow so it makes a PR instead of pushing … #498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/notify-slack-publish-status/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Slack Notify
13 changes: 13 additions & 0 deletions .github/actions/notify-slack-publish-status/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: 'Notify Slack Publish Status'
description: 'Notify Slack with the completion status of the publish action'
inputs:
message:
description: 'Message to send to Slack'
required: true
webhook-url:
description: 'Slack incoming webhook URL'
required: true
runs:
using: 'node20'
main: 'index.js'
52 changes: 52 additions & 0 deletions .github/actions/notify-slack-publish-status/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const core = require('@actions/core');
const webhook = core.getInput('webhook-url');

const run = async () => {
if (webhook) {
try {
await postSlackNotification();
} catch (e) {
console.log(e);
throw new Error(`failed because : ${e}`)
}
} else {
throw new Error('No SDK_PUBLISH_SLACK_WEBHOOK environment variable found');
}
}

const postSlackNotification = async () => {
const message = core.getInput('message');

if (!message) {
throw new Error('No message input found');
}

const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
text: message,
blocks: [
{
type: 'section',
text: {
type: 'mrkdwn',
text: message,
}
}
]
}),
};

const response = await fetch(webhook, options);

if (response.status == 200) {
console.log('Posted message to Slack successfully');
} else {
throw new Error(`Failed to post message to Slack. Status code: ${response.status}`);
}
}

run();

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading