Skip to content

Commit

Permalink
allow user to specify label to look for
Browse files Browse the repository at this point in the history
  • Loading branch information
gcampbell-msft committed Sep 11, 2023
1 parent 7e5397b commit 217c4c5
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 16 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/closeOnRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ on:
token:
description: "Access token that can access and update issues."
required: true
label:
description: "Label for bugs that should be closed upon a release"
required: false
default: "fixed-pending-release"
message:
description: "The message to be included in a comment on the issues to be closed."
required: false
default: ":tada: This issue has now been fixed!"
default: ":tada: This issue has now been fixed! :tada:"
isExternalRelease:
description: "Boolean indicating whether the release is external to GitHub. If it is, no GitHub release will be found."
required: false
Expand Down
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# A GitHub Action that closes issues marked 'fixed-pending-release' upon a new release
# A GitHub Action that closes issues marked for closing upon a new release

This GitHub Action adds a comment to all pull requests that were included in a GitHub release. The comment includes a link to the release, along with a celebratory emoji :tada:

Expand All @@ -7,7 +7,7 @@ This GitHub Action adds a comment to all pull requests that were included in a G
To use this action, you will need to provide your [personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) with `public_repo` permission.

```yaml
name: Close issues marked 'fixed-pending-release' upon a release.
name: Close issues marked for closing upon a release.
on:
release:
types: [published]
Expand All @@ -20,6 +20,7 @@ jobs:
uses: gcampbell/fixed-pending-release/@x.x.x
with:
token: ${{ secrets.GITHUB_TOKEN }}
label: fixed-pending-release
message: ":tada: This issue has now been fixed and is now available in the latest release! :tada:"
```
Expand All @@ -39,17 +40,12 @@ There are a couple of assumptions that this GitHub Actions makes.

This action has the following inputs:

- `token` (required): Your GitHub access token. You can use `${{ secrets.ACCESS_TOKEN }}` to access the value you set as actions repository secret.
- `token` (optional): Your GitHub access token. You can use `${{ secrets.ACCESS_TOKEN }}` to access the value you set as actions repository secret. Default value will be `${{ github.token }}`.
- `label` (option): The label that specifies issues that should be closed upon release.
- `message` (optional): The message to be included in the comment. This is passed to the action as a lodash template string.
Available variables, when `isExternalRelease` is `true` include: `releaseName`, `releaseTag`, `releaseUrl`.
- `isExternalRelease` (optional): Boolean indicating whether the release is external to GitHub. If it is, no GitHub release will be used and thus the above variables aren't available.

## Example

Here's an example of what the comment looks like:

:tada: This issue has now been fixed! The fix is is included in [vx.x.x](https://github.com/owner/repo/releases/tag/vx.x.x) :tada:

## License

This GitHub Action is licensed under the [MIT License](LICENSE).
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ inputs:
description: "Access token that can access and update issues."
required: false
default: '${{ github.token }}'
label:
description: "Label for bugs that should be closed upon a release"
required: false
default: "fixed-pending-release"
message:
description: "The message to be included in a comment on the issues to be closed."
required: false
Expand Down
4 changes: 3 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27013,11 +27013,13 @@ async function run() {
const octokit = github.getOctokit(token);
const { owner, repo } = github.context.repo;

const label = core.getInput("label", { required: false }) || "fixed-pending-release";

const issuesPendingRelease = (await octokit.rest.issues.listForRepo({
owner,
repo,
state: "open"
})).data.filter(i => i.labels.map(l => l.name).includes("fixed-pending-release"));
})).data.filter(i => i.labels.map(l => l.name).includes(label));

// Get the message template from the user input
const externalReleaseDefault = ":tada: This issue has now been fixed and is available in the latest release! :tada:";
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ async function run() {
const octokit = github.getOctokit(token);
const { owner, repo } = github.context.repo;

const label = core.getInput("label", { required: false }) || "fixed-pending-release";

const issuesPendingRelease = (await octokit.rest.issues.listForRepo({
owner,
repo,
state: "open"
})).data.filter(i => i.labels.map(l => l.name).includes("fixed-pending-release"));
})).data.filter(i => i.labels.map(l => l.name).includes(label));

// Get the message template from the user input
const externalReleaseDefault = ":tada: This issue has now been fixed and is available in the latest release! :tada:";
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "close-issues-on-release",
"version": "0.0.5",
"version": "0.0.6",
"description": "Upon release, close issues marked 'fixed-pending-release'",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 217c4c5

Please sign in to comment.