Skip to content

Commit

Permalink
Shift to yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
theballaam96 committed Jan 8, 2024
1 parent 5d7e466 commit 4e5d4a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
14 changes: 2 additions & 12 deletions .github/scripts/pr-analyzer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const axios = require('axios');
const core = require('@actions/core');
const github = require('@actions/github');

async function run() {
try {
Expand Down Expand Up @@ -41,7 +39,6 @@ async function run() {
const prNumber = process.env.PR_NUMBER;
const repo = process.env.GITHUB_REPOSITORY;
const token = process.env.GITHUB_TOKEN;
console.log(`Fetching details for PR ${prNumber} in repository ${repo}`);
const response = await axios.get(`https://api.github.com/repos/${repo}/pulls/${prNumber}`, {
headers: {
Authorization: `Bearer ${token}`,
Expand Down Expand Up @@ -121,22 +118,15 @@ async function run() {
${json_output}
\`\`\`
`

const octokit = new github.getOctokit(process.env.GITHUB_TOKEN);
const new_comment = octokit.issues.createComment({
owner: 'theballaam96',
repo: payload.repository.name,
issue_number: payload.issue.number,
body: message,
});
// await octokit.issues.update({
// owner: 'theballaam96',
// repo: payload.repository.name,
// issue_number: prNumber,
// labels: Array.from([...labels, ...newLabels])
// });

console.log('Commented on pull request successfully.');
console.log(message);
return message;
} catch (error) {
console.error('Error:', error.response ? error.response.data : error.message || error);
process.exit(1);
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/pull-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,22 @@ jobs:
- name: Install project dependencies
run: |
npm install
npm install @actions/core
npm install @actions/github
npm install axios
- name: Analyze Pull Request
run: node .github/scripts/pr-analyzer.js
run: |
PULL_MSG=$(node .github/scripts/pr-analyzer.js)
echo "PULL_MSG=$PULL_MSG" >> $GITHUB_ENV
env:
PR_NUMBER: ${{ github.event.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/github-script@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: ${{ github.event.number }},
owner: context.repo.owner,
repo: context.repo.repo,
body: ${{ env.PULL_MSG }}
})

0 comments on commit 4e5d4a7

Please sign in to comment.