diff --git a/.env.example b/.env.example index 992a137..3527f48 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,3 @@ GH_TOKEN=https://github.com/settings/tokens?type=beta->generate_new_one SLACK_WH_URL=https://api.slack.com/messaging/webhooks->generate_new_webhook_url -REPO_OWNER=adobecom -REPO_NAME=cc \ No newline at end of file +GITHUB_REPOSITORY=adobecom/cc \ No newline at end of file diff --git a/.github/workflows/merged-to-main.yaml b/.github/workflows/merged-to-main.yaml index daaa10c..7c8a6ff 100644 --- a/.github/workflows/merged-to-main.yaml +++ b/.github/workflows/merged-to-main.yaml @@ -33,6 +33,9 @@ jobs: # Checkout repository action - name: Checkout repository uses: actions/checkout@v4 + - name: Install Octakit + run: | + npm i -D @octokit/rest # Sending release notes to cc-changelog channel - name: Sending Release Notes to cc-changelog slack channel uses: actions/github-script@v7 @@ -50,6 +53,9 @@ jobs: # Checkout repository action - name: Check repository uses: actions/checkout@v4 + - name: Install Octakit + run: | + npm i -D @octokit/rest # Sending release notes to cc-changelog channel - name: Sending Release Notes to cc-changelog slack channel uses: actions/github-script@v7 diff --git a/.github/workflows/src/send-slack.js b/.github/workflows/src/send-slack.js index 52289d5..c9a95ee 100644 --- a/.github/workflows/src/send-slack.js +++ b/.github/workflows/src/send-slack.js @@ -1,8 +1,7 @@ const { parseTextToSlackBlocks } = require("./helpers"); // Those env variables are set by an github action automatically -const owner = process.env.REPO_OWNER || ""; -const repo = process.env.REPO_NAME || ""; +const [owner, repo]=process.env.GITHUB_REPOSITORY?.split('/') || ''; const auth = process.env.GH_TOKEN; /** @@ -46,7 +45,6 @@ const sendReleaseNotes = async (prNumber, slackWebHookURL) => { const slackBodyBlocks = { blocks: [...titleBlocks, ...formattedBodyBlocks], }; - console.log("PR Number", prNumber); console.log("Message", slackBodyBlocks); // Send message to Slack webhook @@ -58,6 +56,9 @@ const sendReleaseNotes = async (prNumber, slackWebHookURL) => { }, }).catch(console.error); if (result.status === 200) console.log("Slack Message sent"); + else { + console.log(`Slack Message not sent ${result.status}:${result.statusText}`) + } return result; } catch (e) { console.log(e);