Skip to content

Commit

Permalink
chore: try with PAT token
Browse files Browse the repository at this point in the history
  • Loading branch information
EresDev committed Dec 6, 2024
1 parent f515bff commit 6275a8d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/compute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
permissions: write-all
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PA_PAT_TOKEN: ${{ secrets.PA_PAT_TOKEN }}

steps:
- uses: actions/checkout@v4
Expand Down
18 changes: 15 additions & 3 deletions src/handlers/call-personal-agent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Octokit } from "@octokit/rest";
import { Context } from "../types";

/**
Expand All @@ -9,7 +10,7 @@ import { Context } from "../types";
*
*/
export async function callPersonalAgent(context: Context) {
const { logger, payload, octokit } = context;
const { logger, payload } = context;

const owner = payload.repository.owner.login;
const body = payload.comment.body;
Expand All @@ -27,16 +28,27 @@ export async function callPersonalAgent(context: Context) {

const personalAgentOwner = targetUser[0].replace("/@", "");

logger.info(`Comment received:`, { commenter: owner, personalAgentOwner, comment: body });
logger.info(`Comment received:`, { owner, personalAgentOwner, comment: body });

try {
await octokit.rest.actions.createWorkflowDispatch({
const paOctokit = new Octokit({
auth: process.env.PA_PAT_TOKEN,
});

await paOctokit.rest.actions.createWorkflowDispatch({
owner: personalAgentOwner,
repo: "personal-agent",
workflow_id: "compute.yml",
ref: "development",
});
} catch (error) {
// if (error?.status == 404) {
// logger.error(`${personalAgentOwner} does not have the fork of \`ubiquity-os-marketplace/personal-agent\` plugin to act on this.`);
// } else if (error?.status == 403) {
// logger.error(
// `${personalAgentOwner} did not enable action or did not install UbiquityOS on its fork of \`ubiquity-os-marketplace/personal-agent\` plugin to act on this.`
// );
// }
logger.error(`Error dispatching workflow:`, { err: error, error: new Error() });
throw error;
}
Expand Down

0 comments on commit 6275a8d

Please sign in to comment.