Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
tot-ra committed Sep 12, 2023
1 parent a2c3af3 commit b385866
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
on: [push]
on: [push, pull_request]

jobs:
hello_world_job:
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ runs:
LINK: "https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}"
BRANCH: ${{ env.BRANCH }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_NUMBER: ${{ github.event.number }}
PR_REPO: ${{ github.repository }}
PR_OWNER: ${{ github.repository_owner }}
CLARIFAI_PAT: ${{ inputs.CLARIFAI_PAT }}
Expand Down
22 changes: 13 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9815,29 +9815,33 @@ async function reviewPR() {
try {
const octokit = github.getOctokit(process.env.GITHUB_TOKEN)

console.log("Using this data for PR check", {
PR_OWNER: process.env.PR_OWNER,
PR_NUMBER: process.env.PR_NUMBER,
PR_REPO: process.env.PR_REPO
})

const {data: pullRequest} = await octokit.rest.pulls.get({
const ctx = {
owner: process.env.PR_OWNER,
repo: process.env.PR_REPO,
pull_number: process.env.PR_NUMBER,
}
console.log("Using this data for PR check", ctx)

if(!process.env.PR_NUMBER){
core.setFailed("No PR number detected. Wrong event type?");
return
}

const {data: pullRequest} = await octokit.rest.pulls.get({
...ctx,
mediaType: {
format: 'diff'
}
});

console.log("Received this PR data:", pullRequest);

} catch (error) {
console.error("Failed at getting PR data")
core.setFailed(error.message);
}

try{
console.log("Received this PR data:", pullRequest);

// `who-to-greet` input defined in action metadata file
// const nameToGreet = core.getInput('who-to-greet');
// console.log(`Hello ${nameToGreet}!`);
Expand Down
22 changes: 13 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,33 @@ async function reviewPR() {
try {
const octokit = github.getOctokit(process.env.GITHUB_TOKEN)

console.log("Using this data for PR check", {
PR_OWNER: process.env.PR_OWNER,
PR_NUMBER: process.env.PR_NUMBER,
PR_REPO: process.env.PR_REPO
})

const {data: pullRequest} = await octokit.rest.pulls.get({
const ctx = {
owner: process.env.PR_OWNER,
repo: process.env.PR_REPO,
pull_number: process.env.PR_NUMBER,
}
console.log("Using this data for PR check", ctx)

if(!process.env.PR_NUMBER){
core.setFailed("No PR number detected. Wrong event type?");
return
}

const {data: pullRequest} = await octokit.rest.pulls.get({
...ctx,
mediaType: {
format: 'diff'
}
});

console.log("Received this PR data:", pullRequest);

} catch (error) {
console.error("Failed at getting PR data")
core.setFailed(error.message);
}

try{
console.log("Received this PR data:", pullRequest);

// `who-to-greet` input defined in action metadata file
// const nameToGreet = core.getInput('who-to-greet');
// console.log(`Hello ${nameToGreet}!`);
Expand Down

0 comments on commit b385866

Please sign in to comment.