Skip to content

Commit

Permalink
feat: build for release
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Dec 8, 2021
1 parent ed71587 commit 3d2aed6
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 51 deletions.
68 changes: 43 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,57 @@
# Find Last Issue

GitHub Action to find and export the number of last updated issue that has given labels.
GitHub Action to find and output the number of last updated issue that has given labels and state.

### Inputs
### Action inputs

#### `labels`
| Name | Description | Default |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| **\*** `labels` | Comma or newline-separated list of labels that the issue must have |
| `state` | Issue state. Can be one of the following strings: <ul><li> <code>"open"</code>: if you want to look up for open issues only </li><li> <code>"closed"</code>: if you want to look up for closed issues only </li><li> <code>"all"</code>: if you want to look up for open or closed ones </li></ul> | `"open"` |

> required
### Action outputs

Comma-separated label names that the issue must have.
| Name | Description |
| -------------- | --------------------------------------------------------------------------- |
| `issue_number` | The number of the issue found, if any. |
| `has_found` | Response status. Will be `true` if some issue was found. `false` otherwise. |

### Outputs
### Environment variables

#### `issue_number`

The number of the issue found, if any.

#### `has_found`

Response status. Will be `true` if some issue was found. `false` otherwise.
| Name | Description | Default |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
| `GITHUB_TOKEN` | `GITHUB_TOKEN` or a `repo` scoped [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) | `GITHUB_TOKEN` secret created by GitHub |

## Example usage

```yaml
uses: micalevisk/find-last-issue
with:
labels: 'report,automated issue'
env:
## Optional since it uses the `GITHUB_TOKEN` by default
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
For third-party repositories, you can use the `GITHUB_REPOSITORY` environment variable:
You can use this action along with [create-issue-from-file](https://github.com/peter-evans/create-issue-from-file) action, like:

```yaml
env:
GITHUB_REPOSITORY: owner/repo_name
# ...

- name: Find the last open report issue
id: last_issue
uses: micalevisk/find-last-issue@v1
with:
state: open
## The issue must have the following labels
labels: |
report
automated issue
env:
## Optional since it uses the `GITHUB_TOKEN` created by GitHub by default
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: echo ${{ steps.last_issue.outputs.issue_number }}

- name: Update last updated report issue
if: ${{ steps.last_issue.outputs.has_found == 'true' }}
uses: peter-evans/create-issue-from-file@v3
with:
title: Foo
content-filepath: README.md
issue-number: ${{ steps.last_issue.outputs.issue_number }}
labels: |
report
automated issue
```
94 changes: 69 additions & 25 deletions bundle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8275,30 +8275,30 @@ exports.octokit = new rest_1.Octokit({
debug: core.debug,
info: core.info,
warn: core.warning,
error: core.error
error: core.error,
},
});


/***/ }),

/***/ 5290:
/***/ 416:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.findLastIssueWithLabels = void 0;
exports.findLastIssueWith = void 0;
const client_js_1 = __nccwpck_require__(9368);
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
async function findLastIssueWithLabels(labels) {
const { data: [lastIssueFound] } = await client_js_1.octokit.request('GET /repos/{owner}/{repo}/issues', {
async function findLastIssueWith(labels, state) {
const { data: [lastIssueFound], } = await client_js_1.octokit.request('GET /repos/{owner}/{repo}/issues', {
headers: {
accept: 'application/vnd.github.v3+json',
},
owner,
repo,
state: 'open',
state,
labels: labels.join(','),
sort: 'updated',
direction: 'desc',
Expand All @@ -8307,7 +8307,7 @@ async function findLastIssueWithLabels(labels) {
});
return lastIssueFound;
}
exports.findLastIssueWithLabels = findLastIssueWithLabels;
exports.findLastIssueWith = findLastIssueWith;


/***/ }),
Expand Down Expand Up @@ -8337,31 +8337,75 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(2186));
const find_last_issue_with_labels_1 = __nccwpck_require__(5290);
const utils = __importStar(__nccwpck_require__(6883));
const core_1 = __nccwpck_require__(416);
async function main() {
try {
const labels = core.getInput('labels', { required: true, trimWhitespace: true }).split(',');
const latestReportIssue = await (0, find_last_issue_with_labels_1.findLastIssueWithLabels)(labels);
let hasFoundSome = false;
if (latestReportIssue) {
hasFoundSome = true;
core.setOutput('issue_number', latestReportIssue.number);
}
core.setOutput('has_found', hasFoundSome);
}
catch (err) {
if (err instanceof Error) {
core.error(err.message);
}
core.setFailed('Something went wrong!');
const inputs = {
labels: utils.getInputAsArray('labels', { required: true, trimWhitespace: true }),
state: utils.getInput('state', { required: false, trimWhitespace: true }) || 'open',
};
const latestReportIssue = await (0, core_1.findLastIssueWith)(inputs.labels, inputs.state);
let hasFoundSome = false;
if (latestReportIssue) {
hasFoundSome = true;
utils.setOutput('issue_number', latestReportIssue.number);
}
utils.setOutput('has_found', hasFoundSome);
}
if (require.main === require.cache[eval('__filename')]) {
main();
main().catch((err) => {
if (err instanceof Error) {
utils.error(err.message);
}
utils.setFailed('Something went wrong!');
});
}


/***/ }),

/***/ 6883:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

"use strict";

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.setOutput = exports.getInput = exports.getInputAsArray = exports.error = exports.setFailed = void 0;
const core = __importStar(__nccwpck_require__(2186));
var core_1 = __nccwpck_require__(2186);
Object.defineProperty(exports, "setFailed", ({ enumerable: true, get: function () { return core_1.setFailed; } }));
Object.defineProperty(exports, "error", ({ enumerable: true, get: function () { return core_1.error; } }));
const getInputAsArray = (name, options) => core
.getInput(name, options)
.split(/[\n,]+/)
.map((value) => value.trim())
.filter((val) => val !== '');
exports.getInputAsArray = getInputAsArray;
const getInput = (name, options) => core.getInput(name, options);
exports.getInput = getInput;
const setOutput = (name, value) => core.setOutput(name, value);
exports.setOutput = setOutput;


/***/ }),

/***/ 2020:
Expand Down
2 changes: 1 addition & 1 deletion node_modules/.package-lock.json

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

0 comments on commit 3d2aed6

Please sign in to comment.