diff --git a/.github/linters/.hadolint.yaml b/.github/linters/.hadolint.yaml new file mode 100644 index 0000000..0aa5f7c --- /dev/null +++ b/.github/linters/.hadolint.yaml @@ -0,0 +1,2 @@ +ignored: + - DL3008 \ No newline at end of file diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..1be163f --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,18 @@ +name: Docker Image CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag crawler:"$(date +%s)" \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..7420b09 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,103 @@ + + +# Contributing to innersource-crawler + +First off, thanks for taking the time to contribute! :heart: + +All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us project owners and smooth out the experience for all involved. The team looks forward to your contributions. :tada: + + +## Table of Contents + +- [I Have a Question](#i-have-a-question) +- [I Want To Contribute](#i-want-to-contribute) +- [Reporting Bugs](#reporting-bugs) +- [Suggesting Enhancements](#suggesting-enhancements) +- [Releases](#releases) + +## I Have a Question + +Before you ask a question, it is best to search for existing [Issues](https://github.com/zkoppert/innersource-crawler/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. + +If you then still feel the need to ask a question and need clarification, we recommend the following: + +- Open an [Issue](https://github.com/zkoppert/innersource-crawler/issues/new). +- Provide as much context as you can about what you're running into. +- Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant. + +We will then take care of the issue as soon as possible. + +## I Want To Contribute + +> ### Legal Notice +> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license. + +## Reporting Bugs + + +### Before Submitting a Bug Report + +A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible. + +- Make sure that you are using the latest version. +- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the documentation. If you are looking for support, you might want to check [this section](#i-have-a-question)). +- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/zkoppert/innersource-crawler/issues). +- Collect information about the bug: + - Stack trace (Traceback) + - OS, Platform and Version (Windows, Linux, macOS, x86, ARM) + - Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant. + - Possibly your input and the output +- Can you reliably reproduce the issue? And can you also reproduce it with older versions? + + +### How Do I Submit a Good Bug Report? + +We use GitHub issues to track bugs and errors. If you run into an issue with the project: + +- Open an [Issue](https://github.com/zkoppert/innersource-crawler/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.) +- Explain the behavior you would expect and the actual behavior. +- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case. +- Provide the information you collected in the previous section. + +Once it's filed: + +- The project team will label the issue accordingly. +- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced. +- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be implemented by someone. + +## Suggesting Enhancements + +This section guides you through submitting an enhancement suggestion for innersource-crawler, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions. + + +### Before Submitting an Enhancement + +- Make sure that you are using the latest version. +- Read the documentation carefully and find out if the functionality is already covered, maybe by an individual configuration. +- Perform a [search](https://github.com/zkoppert/innersource-crawler/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one. +- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature or to develop the feature yourself and contribute it to the project. + + +### How Do I Submit a Good Enhancement Suggestion? + +Enhancement suggestions are tracked as [GitHub issues](https://github.com/zkoppert/innersource-crawler/issues). + +- Use a **clear and descriptive title** for the issue to identify the suggestion. +- Provide a **step-by-step description of the suggested enhancement** in as many details as possible. +- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you. +- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. +- **Explain why this enhancement would be useful** to most innersource-crawler users. + +## Releases + +To release a new version, maintainers are to release new versions following semantic versioning and via GitHub Releases. +Once the code is ready to release please do the following +1. Create a [GitHub release](https://github.com/zkoppert/innersource-crawler/releases) based off the current draft and review release notes +2. Ensure that the versioning is correct given the content of the release +3. Check the box to release it to the GitHub Marketplace +4. Publish the release +5. Clone the repository at the release tag locally or in a codespace +6. Authenticate to ghcr.io using [these instructions](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry) +7. `docker build -t ghcr.io/zkoppert/innersource-crawler:v1 .` where v1 is the current major version number +8. `docker push ghcr.io/zkoppert/innersource-crawler:v1` where v1 is the current major version number +9. Update the `README.md` instructions to point to the new docker container diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..771b701 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.8-slim-buster + +WORKDIR /action/workspace +COPY requirements.txt crawler.py /action/workspace/ + +RUN python3 -m pip install --no-cache-dir -r requirements.txt \ + && apt-get -y update \ + && apt-get -y install --no-install-recommends git \ + && rm -rf /var/lib/apt/lists/* + +CMD ["/action/workspace/crawler.py"] +ENTRYPOINT ["python3", "-u"] + +# To run ineractive debug on the docker container +# 1. Comment out the above CMD and ENTRYPOINT lines +# 2. Uncomment the ENTRYPOINT line below + +#ENTRYPOINT ["bash"] \ No newline at end of file diff --git a/README.md b/README.md index 6888e5d..f0906f0 100644 --- a/README.md +++ b/README.md @@ -3,17 +3,51 @@ This project creates a `repos.json` that can be utilized by the [SAP InnerSource Portal][SAP-InnerSource-Portal]. The current approach assumes that the repos that you want to show in the portal are available in a GitHub organization, and that they all are tagged with a certain _topic_. -## Installation +## Support +If you need support using this project or have questions about it, please [open up an issue in this repository](https://github.com/zkoppert/innersource-crawler/issues). Requests made directly to GitHub staff or support team will be redirected here to open an issue. GitHub SLA's and support/services contracts do not apply to this repository. -`pip install -r requirements.txt` +## Use as a GitHub Action -## Usage +1. Create a repository to host this GitHub Action or select an existing repository. +1. Create the env values from the sample workflow below (GH_TOKEN, ORGANIZATION) with your information as repository secrets. More info on creating secrets can be found [here](https://docs.github.com/en/actions/security-guides/encrypted-secrets). +Note: Your GitHub token will need to have read/write access to all the repositories in the organization +1. Copy the below example workflow to your repository and put it in the `.github/workflows/` directory with the file extension `.yml` (ie. `.github/workflows/crawler.yml`) +1. Don't forget to do something with the resulting `repos.json` file. You can [move it to another repository](https://github.com/marketplace/actions/push-a-file-to-another-repository) if needed or [save it as a build artifact](https://github.com/actions/upload-artifact). This will all depend on what you are doing with it and what repository you are running this action out of. + +### Example workflow +```yaml +name: InnerSource repo crawler + +on: + workflow_dispatch: + schedule: + - cron: '00 5 * * *' + +jobs: + build: + name: InnerSource repo crawler + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Run crawler tool + uses: docker://ghcr.io/zkoppert/innersource-crawler:v1 + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + ORGANIZATION: ${{ secrets.ORGANIZATION }} + TOPIC: inner-source +``` + +## Local usage without Docker 1. Copy `.env-example` to `.env` 1. Fill out the `.env` file with a _token_ from a user that has access to the organization to scan (listed below). Tokens should have admin:org or read:org access. 1. Fill out the `.env` file with the exact _topic_ name you are searching for 1. Fill out the `.env` file with the exact _organization_ that you want to search in 1. (Optional) Fill out the `.env` file with the exact _URL_ of the GitHub Enterprise that you want to search in. Keep empty if you want to search in the public `github.com`. +1. `pip install -r requirements.txt` 1. Run `python3 ./crawler.py`, which will create a `repos.json` file containing the relevant metadata for the GitHub repos for the given _topic_ 1. Copy `repos.json` to your instance of the [SAP-InnerSource-Portal][SAP-InnerSource-Portal] and launch the portal as outlined in their installation instructions diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..639deee --- /dev/null +++ b/action.yml @@ -0,0 +1,10 @@ +--- +name: 'InnerSource-Crawler' +author: 'zkoppert' +description: 'A GitHub Action to create a list of InnerSource repos within an organization.' +runs: + using: 'docker' + image: 'Dockerfile' +branding: + icon: 'check-square' + color: 'white'