Skip to content

Commit

Permalink
feat: add labels output (#15)
Browse files Browse the repository at this point in the history
* feat: add labels output

* update test workflow

* set release to manual

* try this way

* update generateFiles.js
  • Loading branch information
lisadean authored Aug 19, 2021
1 parent 8bc2d73 commit f1ff94a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Release to v1

on: workflow_dispatch

jobs:
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ inputs:
token:
description: 'The GITHUB_TOKEN secret'
required: true
outputs:
labels:
description: 'New list of PR labels after action run'
runs:
using: 'node12'
main: 'dist/index.js'
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as minimatch from 'minimatch';
import { Context } from '@actions/github/lib/context';
import { PullRequestEvent, Label as GitHubLabel } from '@octokit/webhooks-types';

const DEBUG = false; // set this to true for extra logging
const DEBUG = true; // set this to true for extra logging

type File = {
sha: string;
Expand Down Expand Up @@ -231,6 +231,13 @@ const handlePullRequest = async () => {
} else {
info('No labels to add');
}

const { data: currentLabels } = await client.rest.issues.listLabelsOnIssue({
...context.repo,
issue_number: number
});
debug(`currentLabels: ${JSON.stringify(currentLabels, null, 2)}`);
core.setOutput('labels', getLabelNames(currentLabels).toString());
};

const run = async () => {
Expand Down
13 changes: 7 additions & 6 deletions test/generateFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ const { join } = require('path');
const { exec } = require('child_process');
/* eslint-disable no-console */

// Usage: node ./test/generateFiles.js <number of lines to add> <create as mock?> <commit and push?>
// Example: node ./test/generateFiles.js 31 yes yes
// a file called 31lines.mock.txt will be generated, committed and pushed to

const generatedFileDirectory = join(__dirname, '..', 'test', 'pr');
// Usage: node ./test/generateFiles.js <number of lines to add> <create as mock?> <server file?> <commit and push?>
// Example: node ./test/generateFiles.js 31 yes yes no
// a file called 31lines.mock.txt will be generated in the server directory but will not be committed and pushed

const lineCount = process.argv[2];
const excludedFile = process.argv[3];
const commitAndPush = process.argv[4];
const serverFile = process.argv[4];
const commitAndPush = process.argv[5];

const generatedFileDirectory = serverFile === 'yes' ? join(__dirname, '..', 'src', 'server') : join(__dirname, '..', 'test', 'pr');

let stuff = '';
for (let i = 0; i < Number(lineCount); i++) {
Expand Down

0 comments on commit f1ff94a

Please sign in to comment.