Skip to content

Commit

Permalink
Merge pull request #8 from planningcenter/wm/tweaks
Browse files Browse the repository at this point in the history
chore: address deprecation warnings and attempt to address flaky Dependabot behavior
  • Loading branch information
wassimk authored Jun 10, 2024
2 parents 551fdc6 + 4ca874f commit 2999b8d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 52 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This is a GitHub action that assigns a PR owner upon opening a pull request.
Sample config, place in `.github/workflows/assign.yml`

```
name: Pull assign
name: Pull Assign
on:
pull_request:
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ inputs:
required: false
default: ${{ github.token }}
runs:
using: "node16"
using: node20
main: "dist/index.js"
53 changes: 28 additions & 25 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9687,38 +9687,41 @@ var __webpack_exports__ = {};
const core = __nccwpck_require__(2186)
const github = __nccwpck_require__(5438)

const run = async () => {
try {
const githubToken = core.getInput('github_token')
async function run() {
const githubToken = core.getInput('github_token')

if (!githubToken) throw Error(`input 'github_token' is required`)
if (!githubToken) throw Error(`input 'github_token' is required`)

const client = github.getOctokit(githubToken)
const owner = github.context.payload.repository.owner.login
const repo = github.context.payload.repository.name
const issue_number = github.context.payload.pull_request.number
const client = github.getOctokit(githubToken)
const owner = github.context.payload.repository.owner.login
const repo = github.context.payload.repository.name
const issue_number = github.context.payload.pull_request.number

const pr = github.context.payload.pull_request
const assignees = pr.assignees
const author = pr.user
const pr = github.context.payload.pull_request
const assignees = pr.assignees
const author = pr.user

if (
(!assignees || assignees.length === 0) &&
author.login !== 'dependabot[bot]'
) {
await client.request(
`POST /repos/${owner}/${repo}/issues/${issue_number}/assignees`,
{ owner, repo, issue_number, assignees: [author.login] }
)
}
} catch (error) {
console.log('Error:', error)
core.error(error)
core.setFailed(error)
console.log(`assignees: ${JSON.stringify(assignees, undefined, 2)}`)
console.log(`author: ${JSON.stringify(author, undefined, 2)}`)

if (
(!assignees || assignees.length === 0) &&
(author.is_bot === false || (author.type && author.type !== 'Bot'))
) {
await client.request(
`POST /repos/${owner}/${repo}/issues/${issue_number}/assignees`,
{ owner, repo, issue_number, assignees: [author.login] }
)
}
}

run()
try {
run()
} catch (error) {
console.log('Error:', error)
core.error(error)
core.setFailed(error.message)
}

})();

Expand Down
53 changes: 28 additions & 25 deletions src/action.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
const core = require('@actions/core')
const github = require('@actions/github')

const run = async () => {
try {
const githubToken = core.getInput('github_token')
async function run() {
const githubToken = core.getInput('github_token')

if (!githubToken) throw Error(`input 'github_token' is required`)
if (!githubToken) throw Error(`input 'github_token' is required`)

const client = github.getOctokit(githubToken)
const owner = github.context.payload.repository.owner.login
const repo = github.context.payload.repository.name
const issue_number = github.context.payload.pull_request.number
const client = github.getOctokit(githubToken)
const owner = github.context.payload.repository.owner.login
const repo = github.context.payload.repository.name
const issue_number = github.context.payload.pull_request.number

const pr = github.context.payload.pull_request
const assignees = pr.assignees
const author = pr.user
const pr = github.context.payload.pull_request
const assignees = pr.assignees
const author = pr.user

if (
(!assignees || assignees.length === 0) &&
author.login !== 'dependabot[bot]'
) {
await client.request(
`POST /repos/${owner}/${repo}/issues/${issue_number}/assignees`,
{ owner, repo, issue_number, assignees: [author.login] }
)
}
} catch (error) {
console.log('Error:', error)
core.error(error)
core.setFailed(error)
console.log(`assignees: ${JSON.stringify(assignees, undefined, 2)}`)
console.log(`author: ${JSON.stringify(author, undefined, 2)}`)

if (
(!assignees || assignees.length === 0) &&
(author.is_bot === false || (author.type && author.type !== 'Bot'))
) {
await client.request(
`POST /repos/${owner}/${repo}/issues/${issue_number}/assignees`,
{ owner, repo, issue_number, assignees: [author.login] }
)
}
}

run()
try {
run()
} catch (error) {
console.log('Error:', error)
core.error(error)
core.setFailed(error.message)
}

0 comments on commit 2999b8d

Please sign in to comment.