Skip to content

Commit

Permalink
post summary (#27)
Browse files Browse the repository at this point in the history
* post summary
  • Loading branch information
sinisastanic authored Jul 21, 2023
1 parent e1aadf7 commit cbb434b
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"rules": {
"@typescript-eslint/no-floating-promises": "warn",
"prettier/prettier": "warn",
"no-console": "warn"
"no-console": "warn",
"i18n-text/no-en": "off"
}
}
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
run: pnpm run build

- name: Execute Automagically
id: automagically
uses: ./
with:
url: 'https://storage.googleapis.com/mocktopus/index.html'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To use this action a token is required. Don't have one? We're here to help.
```yml
- uses: OctoMind-dev/automagically-action-execute@v2
with:
url:
url: <publicly accessible url to your deployment>
token: ${{ secrets.AUTOMAGICALLY_TOKEN }}
testTargetId: <your testTargetId that you also get from us>
```
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ inputs:
automagicallyBaseUrl:
description: 'Base URL of the automagically instance, for switching between production and staging. Defaults to Production url'
required: false
outputs:
testReportUrl:
description: 'Url to resulting test report'
runs:
using: 'node16'
main: 'dist/index.js'
9 changes: 9 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14066,6 +14066,15 @@ try {
body: contentType === 'application/json' ? await response.json() : {}
}, null, 2)}`);
}
const jsonResponse = (await response.json());
if (jsonResponse) {
const testReportId = jsonResponse.testReport.id;
const testReportUrl = `${automagicallyUrl}/testreports/${testReportId}`;
_actions_core__WEBPACK_IMPORTED_MODULE_0__.setOutput('testReportUrl', testReportUrl);
await _actions_core__WEBPACK_IMPORTED_MODULE_0__.summary.addHeading('🐙 Octomind')
.addLink('View your Test Report', testReportUrl)
.write();
}
}
catch (error) {
if (error instanceof Error) {
Expand Down
29 changes: 29 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@ import core from '@actions/core'
import github from '@actions/github'
import fetch from 'node-fetch'

interface ResponseType {
testReport: {
id: string
testTargetId: string
createdAt: string
updatedAt: string
executionUrl: string
context: {
ref?: string
sha?: string
repo: string
owner: string
source: string
issueNumber?: number
}
}
}

const url = core.getInput('url')
if (url.length === 0) {
core.setFailed('url is set to an empty string')
Expand Down Expand Up @@ -70,6 +88,17 @@ try {
)}`
)
}

const jsonResponse = (await response.json()) as ResponseType
if (jsonResponse) {
const testReportId = jsonResponse.testReport.id
const testReportUrl = `${automagicallyUrl}/testreports/${testReportId}`
core.setOutput('testReportUrl', testReportUrl)
await core.summary
.addHeading('🐙 Octomind')
.addLink('View your Test Report', testReportUrl)
.write()
}
} catch (error) {
if (error instanceof Error) {
core.setFailed(
Expand Down

0 comments on commit cbb434b

Please sign in to comment.