From 712173ebc9ac8167470fe9d34b6ad95ce28a7120 Mon Sep 17 00:00:00 2001 From: danibonilha Date: Fri, 22 Dec 2023 13:49:08 -0300 Subject: [PATCH] Test action --- .github/workflows/test-action.yml | 22 ++++++++++++++++++++++ README.md | 4 ++-- badges/coverage.svg | 2 +- dist/index.js | 17 +++++++++++------ src/main.ts | 18 ++++++++++++------ 5 files changed, 48 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/test-action.yml diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml new file mode 100644 index 0000000..ea805e6 --- /dev/null +++ b/.github/workflows/test-action.yml @@ -0,0 +1,22 @@ + +name: Test action + +on: push + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v4 + - name: Test + id: test + uses: ./ + with: + threadName: 'v1.0-test' + channellName: 'bifrost' + message: 'testing action' + webhookUrl: ${{ secrets.HUBOT_WEBHOOK_URl }} + webhookAuth: ${{ secrets.HUBOT_WEBHOOK_AUTH }} diff --git a/README.md b/README.md index b09d23b..d6c0535 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ steps: threadName: 'v1.0' channellName: 'release' message: 'release notes' - webhookUrl: { { secrets.WEBHOOK_URL } } - webhookAuth: { { secrets.WEBHOOK_AUTH } } + webhookUrl: ${{ secrets.WEBHOOK_URL }} + webhookAuth: ${{ secrets.WEBHOOK_AUTH }} ``` ## Initial Local Setup diff --git a/badges/coverage.svg b/badges/coverage.svg index 1063f3d..6cdf1c6 100644 --- a/badges/coverage.svg +++ b/badges/coverage.svg @@ -1 +1 @@ -Coverage: 36.36%Coverage36.36% \ No newline at end of file +Coverage: 28.57%Coverage28.57% \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 30b8624..2ef155f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2761,18 +2761,23 @@ async function createThread() { try { const webhookUrl = core.getInput('webhookUrl'); const webhookAuth = core.getInput('webhookAuth'); - await fetch(webhookUrl, { + const body = JSON.stringify({ + channelName: core.getInput('channelName'), + title: core.getInput('threadName'), + message: core.getInput('message'), + tagUser: '0' + }); + const response = await fetch(webhookUrl, { method: 'POST', headers: { + 'Content-type': 'application/json', Accept: 'application/json', Authorization: webhookAuth }, - body: JSON.stringify({ - channelName: core.getInput('channelName'), - title: core.getInput('threadName'), - message: core.getInput('message') - }) + body }); + core.info(await response.text()); + core.info(body); core.info('Thread created'); } catch (error) { diff --git a/src/main.ts b/src/main.ts index 836287c..e1ff3f3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,19 +9,25 @@ export async function createThread(): Promise { const webhookUrl: string = core.getInput('webhookUrl') const webhookAuth: string = core.getInput('webhookAuth') - await fetch(webhookUrl, { + const body = JSON.stringify({ + channelName: core.getInput('channelName'), + title: core.getInput('threadName'), + message: core.getInput('message'), + tagUser: '0' + }) + + const response = await fetch(webhookUrl, { method: 'POST', headers: { + 'Content-type': 'application/json', Accept: 'application/json', Authorization: webhookAuth }, - body: JSON.stringify({ - channelName: core.getInput('channelName'), - title: core.getInput('threadName'), - message: core.getInput('message') - }) + body }) + core.info(await response.text()) + core.info(body) core.info('Thread created') } catch (error) { // Fail the workflow run if an error occurs