Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
fix(action): repo, context passed as parameters #1
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiejaoude committed Sep 5, 2020
1 parent 153229e commit ace77ab
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/community.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ jobs:
- uses: EddieJaoudeCommunity/gh-action-community@main
with:
github-token: ${{secrets.GITHUB_TOKEN}}
repo: github
context: context
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ inputs:
github-token:
description: 'repo access'
required: true
repo:
description: 'repo info'
required: true
context:
description: 'context of repo'
required: true
runs:
using: 'node12'
main: 'index.js'
28 changes: 15 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
const core = require("@actions/core");
const github = require("@actions/github");
const core = require('@actions/core');
const github = require('@actions/github');

(async () => {
try {
// const githubSecret = core.getInput("github-secret");
// const githubSecret = core.getInput('github-secret');
const repo = core.getInput('repo');
const context = core.getInput('context');

const creator = github.context.payload.sender.login;
const opts = github.issues.listForRepo.endpoint.merge({
...github.context.issue,
const creator = context.payload.sender.login;
const opts = repo.issues.listForRepo.endpoint.merge({
...context.issue,
creator,
state: "all",
state: 'all',
});
const issues = await github.paginate(opts);
const issues = await repo.paginate(opts);

for (const issue of issues) {
if (issue.number === github.context.issue.number) {
if (issue.number === context.issue.number) {
continue;
}

Expand All @@ -23,11 +25,11 @@ const github = require("@actions/github");
}
}

await github.issues.createComment({
await repo.issues.createComment({
issue_number: github.context.issue.number,
owner: github.context.repo.owner,
repo: github.context.repo.repo,
body: "Welcome, new contributor!",
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Welcome, new contributor!',
});
} catch (error) {
core.setFailed(error.message);
Expand Down

0 comments on commit ace77ab

Please sign in to comment.