Update pr-first-response.yml
This commit is contained in:
committed by
GitHub
parent
eb0ddbd729
commit
16a02e0827
52
.github/workflows/pr-first-response.yml
vendored
52
.github/workflows/pr-first-response.yml
vendored
@@ -8,19 +8,43 @@ jobs:
|
|||||||
send-response:
|
send-response:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch random comment 🗣️
|
- name: Install dependencies
|
||||||
uses: JamesIves/fetch-api-data-action@v2.1.0
|
run: |
|
||||||
with:
|
npm install node-fetch@2
|
||||||
ENDPOINT: https://collaboratorsv2.euwest01.umbraco.io/umbraco/api/comments/PostComment
|
- name: Fetch random comment 🗣️ and add it to the PR
|
||||||
CONFIGURATION: '{ "method": "POST", "headers": {"Authorization": "Bearer ${{ secrets.OUR_BOT_API_TOKEN }}", "Content-Type": "application/json" }, "body": { "repo": "${{ github.repository }}", "number": "${{ github.event.number }}", "actor": "${{ github.actor }}", "commentType": "opened-pr-first-comment"} }'
|
uses: actions/github-script@v6
|
||||||
- name: Add PR comment
|
|
||||||
if: "${{ env.fetch-api-data != '' }}"
|
|
||||||
uses: actions/github-script@v5
|
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
github.rest.issues.createComment({
|
const fetch = require('node-fetch')
|
||||||
issue_number: context.issue.number,
|
|
||||||
owner: context.repo.owner,
|
const response = await fetch('https://collaboratorsv2.euwest01.umbraco.io/umbraco/api/comments/PostComment', {
|
||||||
repo: context.repo.repo,
|
method: 'post',
|
||||||
body: `${{ env.fetch-api-data }}`
|
body: JSON.stringify({
|
||||||
})
|
repo: '${{ github.repository }}',
|
||||||
|
number: '${{ github.event.number }}',
|
||||||
|
actor: '${{ github.actor }}',
|
||||||
|
commentType: 'opened-pr-first-comment'
|
||||||
|
}),
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer ${{ secrets.OUR_BOT_API_TOKEN }}',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = await response.text();
|
||||||
|
|
||||||
|
if(response.status === 200 && data !== '') {
|
||||||
|
github.rest.issues.createComment({
|
||||||
|
issue_number: context.issue.number,
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
body: data
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log("Status code did not indicate success:", response.status);
|
||||||
|
console.log("Returned data:", data);
|
||||||
|
}
|
||||||
|
} catch(error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user