Skip to content

Commit 413f39f

Browse files
authored
Merge pull request #21 from zkoppert/github-action
GitHub action
2 parents e8a7471 + 2048ffb commit 413f39f

File tree

6 files changed

+188
-3
lines changed

6 files changed

+188
-3
lines changed

.github/linters/.hadolint.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ignored:
2+
- DL3008

.github/workflows/docker-image.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Build the Docker image
18+
run: docker build . --file Dockerfile --tag crawler:"$(date +%s)"

CONTRIBUTING.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<!-- markdownlint-disable MD013 -->
2+
<!-- omit in toc -->
3+
# Contributing to innersource-crawler
4+
5+
First off, thanks for taking the time to contribute! :heart:
6+
7+
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:
8+
9+
<!-- omit in toc -->
10+
## Table of Contents
11+
12+
- [I Have a Question](#i-have-a-question)
13+
- [I Want To Contribute](#i-want-to-contribute)
14+
- [Reporting Bugs](#reporting-bugs)
15+
- [Suggesting Enhancements](#suggesting-enhancements)
16+
- [Releases](#releases)
17+
18+
## I Have a Question
19+
20+
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.
21+
22+
If you then still feel the need to ask a question and need clarification, we recommend the following:
23+
24+
- Open an [Issue](https://github.com/zkoppert/innersource-crawler/issues/new).
25+
- Provide as much context as you can about what you're running into.
26+
- Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant.
27+
28+
We will then take care of the issue as soon as possible.
29+
30+
## I Want To Contribute
31+
32+
> ### Legal Notice <!-- omit in toc -->
33+
> 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.
34+
35+
## Reporting Bugs
36+
37+
<!-- omit in toc -->
38+
### Before Submitting a Bug Report
39+
40+
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.
41+
42+
- Make sure that you are using the latest version.
43+
- 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)).
44+
- 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).
45+
- Collect information about the bug:
46+
- Stack trace (Traceback)
47+
- OS, Platform and Version (Windows, Linux, macOS, x86, ARM)
48+
- Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant.
49+
- Possibly your input and the output
50+
- Can you reliably reproduce the issue? And can you also reproduce it with older versions?
51+
52+
<!-- omit in toc -->
53+
### How Do I Submit a Good Bug Report?
54+
55+
We use GitHub issues to track bugs and errors. If you run into an issue with the project:
56+
57+
- 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.)
58+
- Explain the behavior you would expect and the actual behavior.
59+
- 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.
60+
- Provide the information you collected in the previous section.
61+
62+
Once it's filed:
63+
64+
- The project team will label the issue accordingly.
65+
- 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.
66+
- 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.
67+
68+
## Suggesting Enhancements
69+
70+
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.
71+
72+
<!-- omit in toc -->
73+
### Before Submitting an Enhancement
74+
75+
- Make sure that you are using the latest version.
76+
- Read the documentation carefully and find out if the functionality is already covered, maybe by an individual configuration.
77+
- 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.
78+
- 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.
79+
80+
<!-- omit in toc -->
81+
### How Do I Submit a Good Enhancement Suggestion?
82+
83+
Enhancement suggestions are tracked as [GitHub issues](https://github.com/zkoppert/innersource-crawler/issues).
84+
85+
- Use a **clear and descriptive title** for the issue to identify the suggestion.
86+
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
87+
- **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.
88+
- 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.
89+
- **Explain why this enhancement would be useful** to most innersource-crawler users.
90+
91+
## Releases
92+
93+
To release a new version, maintainers are to release new versions following semantic versioning and via GitHub Releases.
94+
Once the code is ready to release please do the following
95+
1. Create a [GitHub release](https://github.com/zkoppert/innersource-crawler/releases) based off the current draft and review release notes
96+
2. Ensure that the versioning is correct given the content of the release
97+
3. Check the box to release it to the GitHub Marketplace
98+
4. Publish the release
99+
5. Clone the repository at the release tag locally or in a codespace
100+
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)
101+
7. `docker build -t ghcr.io/zkoppert/innersource-crawler:v1 .` where v1 is the current major version number
102+
8. `docker push ghcr.io/zkoppert/innersource-crawler:v1` where v1 is the current major version number
103+
9. Update the `README.md` instructions to point to the new docker container

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM python:3.8-slim-buster
2+
3+
WORKDIR /action/workspace
4+
COPY requirements.txt crawler.py /action/workspace/
5+
6+
RUN python3 -m pip install --no-cache-dir -r requirements.txt \
7+
&& apt-get -y update \
8+
&& apt-get -y install --no-install-recommends git \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
CMD ["/action/workspace/crawler.py"]
12+
ENTRYPOINT ["python3", "-u"]
13+
14+
# To run ineractive debug on the docker container
15+
# 1. Comment out the above CMD and ENTRYPOINT lines
16+
# 2. Uncomment the ENTRYPOINT line below
17+
18+
#ENTRYPOINT ["bash"]

README.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,51 @@
33

44
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_.
55

6-
## Installation
6+
## Support
7+
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.
78

8-
`pip install -r requirements.txt`
9+
## Use as a GitHub Action
910

10-
## Usage
11+
1. Create a repository to host this GitHub Action or select an existing repository.
12+
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).
13+
Note: Your GitHub token will need to have read/write access to all the repositories in the organization
14+
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`)
15+
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.
16+
17+
### Example workflow
18+
```yaml
19+
name: InnerSource repo crawler
20+
21+
on:
22+
workflow_dispatch:
23+
schedule:
24+
- cron: '00 5 * * *'
25+
26+
jobs:
27+
build:
28+
name: InnerSource repo crawler
29+
runs-on: ubuntu-latest
30+
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v2
34+
35+
- name: Run crawler tool
36+
uses: docker://ghcr.io/zkoppert/innersource-crawler:v1
37+
env:
38+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
39+
ORGANIZATION: ${{ secrets.ORGANIZATION }}
40+
TOPIC: inner-source
41+
```
42+
43+
## Local usage without Docker
1144
1245
1. Copy `.env-example` to `.env`
1346
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.
1447
1. Fill out the `.env` file with the exact _topic_ name you are searching for
1548
1. Fill out the `.env` file with the exact _organization_ that you want to search in
1649
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`.
50+
1. `pip install -r requirements.txt`
1751
1. Run `python3 ./crawler.py`, which will create a `repos.json` file containing the relevant metadata for the GitHub repos for the given _topic_
1852
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
1953

action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: 'InnerSource-Crawler'
3+
author: 'zkoppert'
4+
description: 'A GitHub Action to create a list of InnerSource repos within an organization.'
5+
runs:
6+
using: 'docker'
7+
image: 'Dockerfile'
8+
branding:
9+
icon: 'check-square'
10+
color: 'white'

0 commit comments

Comments
 (0)