From 0151419557d6080c6d98363f5af5538458cccd1b Mon Sep 17 00:00:00 2001 From: vsoch Date: Thu, 5 Mar 2020 13:42:23 -0700 Subject: [PATCH 1/3] exposing variable as an envar Signed-off-by: vsoch --- README.md | 23 ++++++++++++++++++++--- action.yml | 5 +++++ scripts/generate-first-issues.py | 5 +++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2cd3a8b..e939ceb 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,12 @@ https://github.com/spack/spack hpc,package-management https://github.com/singularityhub/sregistry containers,singularity ``` +### `label` + +**optional** By default, the repository will filter down to issues labeled with "good first issue". +However, you can change this by setting this variable to something else. + + ## Example usage ```yaml @@ -33,15 +39,26 @@ https://github.com/singularityhub/sregistry containers,singularity - name: Checkout Code uses: actions/checkout@v2 - name: Generate First Issues - uses: rseng/good-first-issues@v1.0.1 + uses: rseng/good-first-issues@v1.0.2 with: repos-file: '.github/repos.txt' token: ${{ secrets.GITHUB_TOKEN }} ``` You only need to define repos-file if you change the path (note that the above is changed from .github/repos.txt). It's -highly recommended that you don't use master branch, but instead -a version release or commit (as shown above). +highly recommended that you don't use master branch, but instead a version release or commit (as shown above). +Here is how you might update the label used: + +```yaml + steps: + - name: Checkout Code + uses: actions/checkout@v2 + - name: Generate First Issues + uses: rseng/good-first-issues@v1.0.2 + with: + label: 'bug' + token: ${{ secrets.GITHUB_TOKEN }} +``` ## Examples diff --git a/action.yml b/action.yml index db30005..1880ead 100644 --- a/action.yml +++ b/action.yml @@ -9,6 +9,10 @@ inputs: description: 'The relative path in the repository for the repos.txt' required: true default: 'repos.txt' + label: + description: 'The label to generate an interface for' + required: true + default: 'good first issue' token: description: > Auth token used to fetch the repository. @@ -19,3 +23,4 @@ runs: env: REPOS_FILE: ${{ inputs.repos-file }} GITHUB_TOKEN: ${{ inputs.token }} + ISSUE_LABEL: ${{ inputs.label }} diff --git a/scripts/generate-first-issues.py b/scripts/generate-first-issues.py index 03b3caa..63cce60 100755 --- a/scripts/generate-first-issues.py +++ b/scripts/generate-first-issues.py @@ -10,6 +10,7 @@ # GitHub Workflow - we get variables from environment REPOS_FILE = os.environ.get("REPOS_FILE") +ISSUE_LABEL = os.environ.get("ISSUE_LABEL", "good first issue") if not REPOS_FILE: sys.exit(f"{REPOS_FILE} must be defined.") @@ -26,7 +27,7 @@ # Must authenticate headers = {"Authorization": f"token {token}"} -data = {"state": "open", "labels": "good first issue"} +data = {"state": "open", "labels": ISSUE_LABEL} # Documentation base is located at docs output_dir = "/github/workspace/docs/_issues" @@ -60,7 +61,7 @@ # Add labels as tags tags = set([x["name"] for x in issue["labels"]]) - tags.remove("good first issue") + tags.remove(ISSUE_LABEL) tags = list(tags) if extra_tags: From 13a2753b55449bff4065e18636e58cd2c462beaa Mon Sep 17 00:00:00 2001 From: vsoch Date: Sat, 7 Mar 2020 15:45:13 -0700 Subject: [PATCH 2/3] adding ability to specify collections subfolders Signed-off-by: vsoch --- CHANGELOG.md | 1 + README.md | 23 +++++++++++++++++++++++ action.yml | 5 +++++ scripts/entrypoint.sh | 8 +++++++- scripts/generate-first-issues.py | 7 ++++++- 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4671f83..49d4013 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Critical items to know are: - changed behaviour (recipe sections work differently) ## [master](https://github.com/rseng/good-first-issues/tree/master) + - add issue label and collection folder parameters (v1.0.2) - ensure tags are sorted (v1.0.1) - first tagged released associated with blog post (v1.0.0) diff --git a/README.md b/README.md index e939ceb..f89cf83 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,13 @@ https://github.com/singularityhub/sregistry containers,singularity However, you can change this by setting this variable to something else. +### `collection` + +**optional** By default, the issues will each produce a markdown file to add to the "docs" GitHub pages folder, +in a subfolder named by this variable, which defaults to _issues. If you produce a site that has more +than one collection, you can change this to something else. + + ## Example usage ```yaml @@ -60,6 +67,22 @@ Here is how you might update the label used: token: ${{ secrets.GITHUB_TOKEN }} ``` +Finally, if I want to instead output to a folder called `_another` (a Jekyll collection name) +as a relative path to the docs folder, I can set that as follows: + + +```yaml + steps: + - name: Checkout Code + uses: actions/checkout@v2 + - name: Generate First Issues + uses: rseng/good-first-issues@v1.0.2 + with: + collection: '_another' + token: ${{ secrets.GITHUB_TOKEN }} +``` + + ## Examples - [awesome-rseng](https://github.com/rseng/awesome-rseng/blob/master/.github/workflows/generate-first-issues.yml) to generate first issues from the awesome-rseng repository, with repos listed in [.github/repos.txt](https://github.com/rseng/awesome-rseng/blob/master/.github/repos.txt) diff --git a/action.yml b/action.yml index 1880ead..dbe039d 100644 --- a/action.yml +++ b/action.yml @@ -9,6 +9,10 @@ inputs: description: 'The relative path in the repository for the repos.txt' required: true default: 'repos.txt' + collection: + description: 'The relative path in docs for the collection folder to output to' + required: true + default: '_issues' label: description: 'The label to generate an interface for' required: true @@ -24,3 +28,4 @@ runs: REPOS_FILE: ${{ inputs.repos-file }} GITHUB_TOKEN: ${{ inputs.token }} ISSUE_LABEL: ${{ inputs.label }} + COLLECTION_FOLDER: ${{ inputs.collection }} diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index 38eba63..ecb1a8b 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -3,6 +3,11 @@ set -eu set -o pipefail +# Get the relative path of the folder in docs to write output +if [ -z "${COLLECTION_FOLDER}" ]; then + COLLECTION_FOLDER="_issues" +fi + # If the docs folder isn't created, do so. if [ ! -d "/github/workspace/docs" ]; then printf "Creating docs folder for GitHub pages\n" @@ -11,7 +16,8 @@ fi # Cleanup old set of first issues printf "Cleaning up previous first issues...\n" -rm -rf /github/workspace/docs/_issues +rm -rf "/github/workspace/docs/${COLLECTION_FOLDER}" +export COLLECTION_FOLDER # Generate first issues python3 /generate-first-issues.py diff --git a/scripts/generate-first-issues.py b/scripts/generate-first-issues.py index 63cce60..d22ee4e 100755 --- a/scripts/generate-first-issues.py +++ b/scripts/generate-first-issues.py @@ -11,6 +11,7 @@ # GitHub Workflow - we get variables from environment REPOS_FILE = os.environ.get("REPOS_FILE") ISSUE_LABEL = os.environ.get("ISSUE_LABEL", "good first issue") +COLLECTION_FOLDER = os.environ.get("COLLECTION_FOLDER", "_issues") if not REPOS_FILE: sys.exit(f"{REPOS_FILE} must be defined.") @@ -30,7 +31,11 @@ data = {"state": "open", "labels": ISSUE_LABEL} # Documentation base is located at docs -output_dir = "/github/workspace/docs/_issues" +output_dir = "/github/workspace/docs/%s" % COLLECTION_FOLDER + +# Print metadata for user +print("Issue label: [%s]" % ISSUE_LABEL) +print("Collection output folder: [%s]" % output_dir) if not os.path.exists(output_dir): os.mkdir(output_dir) From 555553c641eefd7a80a82c3d8fb67c837ec4a092 Mon Sep 17 00:00:00 2001 From: vsoch Date: Sat, 7 Mar 2020 16:35:08 -0700 Subject: [PATCH 3/3] extra tags should be optional Signed-off-by: vsoch --- CHANGELOG.md | 2 +- scripts/generate-first-issues.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49d4013..75ccde9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ Critical items to know are: - changed behaviour (recipe sections work differently) ## [master](https://github.com/rseng/good-first-issues/tree/master) - - add issue label and collection folder parameters (v1.0.2) + - add issue label and collection folder parameters, extra tags optional (v1.0.2) - ensure tags are sorted (v1.0.1) - first tagged released associated with blog post (v1.0.0) diff --git a/scripts/generate-first-issues.py b/scripts/generate-first-issues.py index d22ee4e..b7c8c2f 100755 --- a/scripts/generate-first-issues.py +++ b/scripts/generate-first-issues.py @@ -42,7 +42,14 @@ # Load repos for line in lines: - repo, extra_tags = line.strip().split(" ") + + # Extra tags are optional, separated by comma + extra_tags = "" + try: + repo, extra_tags = line.strip().split(" ") + except ValueError: + repo = line.strip() + extra_tags = extra_tags.split(",") repo = "/".join(repo.split("/")[-2:]) url = api_base.format(repo=repo)