Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: expire inputs #43

Merged
merged 2 commits into from
Jun 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions .github/workflows/expire.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ name: 'expire'
on:
workflow_call:
inputs:
owner:
description: 'The GitHub organization or repository owner.'
type: 'string'
required: true
repo:
description: 'The repository name.'
description: 'The owner and repository name. For example, Codertocat/Hello-World'
type: 'string'
required: true
expiryHours:
Expand All @@ -29,11 +25,13 @@ jobs:
result-encoding: 'string'
retries: 3
script: |-
const repoOwner = String('${{ inputs.repo }}').split('/')[0]
drevell marked this conversation as resolved.
Show resolved Hide resolved
const repoName = String('${{ inputs.repo }}').split('/')[1]
const cutoffMs = ${{ inputs.expiryHours }} * 60 * 60 * 1000
const now = new Date();
const pulls = await github.rest.pulls.list({
owner: '${{ inputs.owner }}',
repo: '${{ inputs.repo }}',
owner: repoOwner,
repo: repoName,
state: 'open',
per_page: 100,
});
Expand All @@ -46,8 +44,8 @@ jobs:

pulls.data.forEach(async (pull) => {
const files = await github.rest.pulls.listFiles({
owner: '${{ inputs.owner }}',
repo: '${{ inputs.repo }}',
owner: repoOwner,
repo: repoName,
pull_number: pull['number'],
})

Expand All @@ -64,8 +62,8 @@ jobs:
core.info(`Closing #${pull['number']} (${pull['title']})`);

await github.rest.pulls.update({
owner: '${{ inputs.owner }}',
repo: '${{ inputs.repo }}',
owner: repoOwner,
repo: repoName,
pull_number: pull['number'],
state: 'closed',
});
Expand Down