-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description Set up a repository with a dummy Maven project and workflows pushing to Maven Central. For regular updates a script is provided, which automatically creates a PR. It also provides init branches for the license and codeowners file. If these branches are present, a PR is automatically created. It contains further instructions for the correct setup. # Verification Manually verified on the `test` repository.
- Loading branch information
Showing
31 changed files
with
709 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"version": "0.2", | ||
"language": "en", | ||
"words": [ | ||
"cpus", | ||
"Hapag", | ||
"Infracost", | ||
"javadoc", | ||
"javadocs", | ||
"oidc", | ||
"Repology", | ||
"sonatype", | ||
"tflint", | ||
"tfsec" | ||
], | ||
"ignoreWords": [ | ||
"Buildx", | ||
"DOCKERHUB", | ||
"amannn", | ||
"aquasecurity", | ||
"automerge", | ||
"automerged", | ||
"buildcache", | ||
"buildx", | ||
"codeowners", | ||
"codeql", | ||
"conventionalcommits", | ||
"datasource", | ||
"dorny", | ||
"hadolint", | ||
"hlag", | ||
"hmarr", | ||
"ibiqlik", | ||
"kayma", | ||
"kayman", | ||
"ludeeus", | ||
"markdownlint", | ||
"mktemp", | ||
"nullglob", | ||
"ossrh", | ||
"pascalfrenz", | ||
"releaserc", | ||
"rhysd", | ||
"ruleset", | ||
"sarif", | ||
"shellcheck", | ||
"shuf", | ||
"shunsuke", | ||
"signoff", | ||
"temurin", | ||
"tfstate", | ||
"vuln" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
# Default state for all rules | ||
default: true | ||
|
||
# MD013/line-length - Line length | ||
MD013: | ||
# Number of characters | ||
line_length: 132 | ||
# Number of characters for headings | ||
heading_line_length: 132 | ||
# Number of characters for code blocks | ||
code_block_line_length: 132 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
extends: default | ||
|
||
rules: | ||
line-length: | ||
max: 132 | ||
comments: | ||
min-spaces-from-content: 1 # Renovate uses 1 space only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.1.0 | ||
hooks: | ||
- id: fix-byte-order-marker | ||
- id: check-added-large-files | ||
args: | ||
- "--maxkb=20" | ||
- id: check-case-conflict | ||
- id: check-yaml | ||
- id: check-json | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: mixed-line-ending | ||
- id: check-merge-conflict | ||
- id: check-shebang-scripts-are-executable | ||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: v2.6.0 | ||
hooks: | ||
- id: prettier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* @hapag-lloyd/organization-defaults | ||
|
||
# license file shouldn't be changed and needs to be reviewed by lawyers | ||
LICENSE @hapag-lloyd/organization-defaults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Contribution guide | ||
|
||
We appreciate your thought to contribute to open source. :heart: We want to make contributing as easy as possible. You are welcome to: | ||
|
||
- Report a bug | ||
- Discuss the current state of the code | ||
- Submit a fix | ||
- Propose new features | ||
|
||
We use [Github Flow](https://guides.github.com/introduction/flow/index.html), so all code changes happen through pull | ||
requests. We actively welcome your pull requests: | ||
|
||
1. Fork the repo and create your branch from `main`. | ||
2. If you've added code, check one of the examples. | ||
3. Make sure your code lints. | ||
4. Raise a pull request. | ||
|
||
## Documentation | ||
|
||
We use [pre-commit](https://pre-commit.com/) for some default checks which are fast and find the most common errors. | ||
|
||
## License | ||
|
||
By contributing, you agree that your contributions will be licensed under the license available at | ||
[LICENSE](blob/main/LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
name: Bug report | ||
about: Found a bug? Report it! | ||
title: '' | ||
labels: new, bug | ||
assignees: '' | ||
--- | ||
|
||
<!-- Before submitting a bug, make sure that you meet the following requirements: | ||
1. use the latest version of the module | ||
2. read the documentation | ||
--> | ||
|
||
# Describe the bug | ||
|
||
A clear and concise description of what the bug is. | ||
|
||
# To Reproduce | ||
|
||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
# Expected behavior | ||
|
||
A clear and concise description of what you expected to happen. | ||
|
||
# Additional context | ||
|
||
Add any other context about the problem here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
name: Feature Request | ||
about: Propose a new feature | ||
title: '' | ||
labels: new, enhancement | ||
assignees: '' | ||
--- | ||
|
||
# Describe the solution you'd like | ||
|
||
<!-- | ||
Provide a clear and concise description of what you want to happen. Add some sentences to describe the use case | ||
to be solved by this feature. | ||
--> | ||
|
||
# Describe alternatives you've considered | ||
|
||
<!-- | ||
Let us know about other solutions you've tried or researched. | ||
--> | ||
|
||
# Suggest a solution | ||
|
||
<!-- | ||
Things to include: | ||
- details of the technical implementation | ||
- tradeoffs made in design decisions | ||
-caveats and considerations for the future | ||
If there are multiple solutions, please present each one separately. Save comparisons for the very end. | ||
--> | ||
|
||
# Additional context | ||
|
||
<!-- | ||
Is there anything else you can add about the proposal? | ||
You might want to link to related issues here, if you haven't already. | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Description | ||
|
||
What is the overall goal of your PR? Which problem does it solve? Please also include relevant motivation and context. | ||
List any dependencies that are required for this change. | ||
|
||
Fixes #(issue number) | ||
|
||
# Migrations required | ||
|
||
yes: please describe the migration | ||
no: please delete the whole paragraph | ||
|
||
# Verification | ||
|
||
Please describe the test cases you used to verify your code. Did you check the change in your environment? | ||
|
||
# Checklist | ||
|
||
- [ ] My code follows the style guidelines of the project | ||
- [ ] I have performed a self-review of my own code | ||
- [ ] I have made corresponding changes to the documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
$schema: "https://docs.renovatebot.com/renovate-schema.json", | ||
extends: ["github>Hapag-Lloyd/Renovate-Global-Configuration"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
# | ||
# This script updates the current repository with the latest version of the templates. It creates a new branch and a pull request. | ||
# | ||
|
||
function ensure_dependencies_or_exit() { | ||
if ! command -v gh &> /dev/null; then | ||
echo "gh is not installed. Please install it from https://cli.github.com/" | ||
exit 1 | ||
fi | ||
} | ||
|
||
function ensure_repo_preconditions_or_exit() { | ||
# ensure main branch | ||
if [ "$(git branch --show-current)" != "main" ]; then | ||
echo "The current branch is not main. Please switch to the main branch." | ||
exit 1 | ||
fi | ||
|
||
# ensure a clean working directory | ||
if [ -n "$(git status --porcelain)" ]; then | ||
echo "The working directory is not clean. Please use a clean copy so no unintended changes are merged." | ||
exit 1 | ||
fi | ||
} | ||
|
||
function create_and_show_pr_for_init_branch() { | ||
local branch_name=$1 | ||
|
||
if git branch | grep -q "$branch_name"; then | ||
git checkout "$branch_name" | ||
|
||
title=$(head -n1 pr-description.md) | ||
body=$(tail -n2 pr-description.md) | ||
|
||
rm pr-description.md | ||
git add . | ||
git commit -m "remove the PR description" | ||
git push | ||
|
||
gh pr create --title "$title" --body "$body" --base main --head "$branch_name" | ||
gh pr view --web | ||
fi | ||
} | ||
|
||
ensure_dependencies_or_exit | ||
ensure_repo_preconditions_or_exit | ||
|
||
latest_template_path=$(mktemp -d -t repository-template-XXXXX) | ||
new_branch_name=$(basename "$latest_template_path") | ||
|
||
# clone the default branch to get the latest version of the template files | ||
gh repo clone https://github.com/Hapag-Lloyd/Repository-Template-Maven.git "$latest_template_path" | ||
|
||
# create a new branch to update the templates | ||
git checkout -b "$new_branch_name" | ||
|
||
# update issue templates | ||
cp -r "$latest_template_path/.github/ISSUE_TEMPLATE" .github/ | ||
|
||
# update pull request template | ||
cp "$latest_template_path/.github/PULL_REQUEST_TEMPLATE.md" .github/ | ||
|
||
# update contributing guidelines | ||
cp "$latest_template_path/.github/CONTRIBUTING.md" .github/ | ||
|
||
# update the update scripts | ||
cp "$latest_template_path/.github"/update_*.sh .github/ | ||
|
||
# create a commit, push it and open a pull request | ||
git add .github | ||
git commit -m "chore: update project templates" | ||
git push --set-upstream origin "$new_branch_name" | ||
|
||
gh pr create --title "chore: update project templates" --body "This PR updates the project templates." --base main --head "$new_branch_name" | ||
|
||
echo "The project templates have been updated. Please review and merge the pull request." | ||
gh pr view --web | ||
|
||
# create PR to initialize the CODEOWNERS file | ||
branch_name="kayma/init-codeowners" | ||
|
||
if git branch | grep -q "$branch_name"; then | ||
git checkout "$branch_name" | ||
|
||
title=$(head -n1 pr-description.md) | ||
body=$(tail -n2 pr-description.md) | ||
|
||
rm pr-description.md | ||
git add . | ||
git commit -m "remove the PR description" | ||
git push | ||
|
||
gh pr create --title "$title" --body "$body" --base main --head "$branch_name" | ||
gh pr view --web | ||
fi | ||
|
||
# initialize the LICENSE and CODEOWNERS file | ||
|
||
# find all init- branches | ||
init_branches=$(git branch | grep "init-") | ||
|
||
for init_branch in $init_branches; do | ||
create_and_show_pr_for_init_branch "$init_branch" | ||
done | ||
|
||
rm -rf "$latest_template_path" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# This script updates the current repository with the latest version of the workflows. It creates a new branch and a pull request. | ||
# | ||
|
||
function ensure_dependencies_or_exit() { | ||
if ! command -v gh &> /dev/null; then | ||
echo "gh is not installed. Please install it from https://cli.github.com/" | ||
exit 1 | ||
fi | ||
} | ||
|
||
function ensure_repo_preconditions_or_exit() { | ||
# ensure main branch | ||
if [ "$(git branch --show-current)" != "main" ]; then | ||
echo "The current branch is not main. Please switch to the main branch." | ||
exit 1 | ||
fi | ||
|
||
# ensure a clean working directory | ||
if [ -n "$(git status --porcelain)" ]; then | ||
echo "The working directory is not clean. Please use a clean copy so no unintended changes are merged." | ||
exit 1 | ||
fi | ||
} | ||
|
||
ensure_dependencies_or_exit | ||
ensure_repo_preconditions_or_exit | ||
|
||
current_directory=$(pwd) | ||
latest_workflows_path=$(mktemp -d -t repository-template-XXXXX) | ||
|
||
gh repo clone https://github.com/Hapag-Lloyd/Workflow-Templates.git "$latest_workflows_path" | ||
|
||
# update the workflows | ||
( | ||
cd "$latest_workflows_path" || exit 7 | ||
|
||
./update-workflows.sh "$current_directory" maven | ||
) | ||
|
||
rm -rf "$latest_workflows_path" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
name: Build Java PR | ||
|
||
# yamllint disable-line rule:truthy | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
default: | ||
uses: Hapag-Lloyd/Workflow-Templates/.github/workflows/maven_java_callable.yml@c34ea75ff9e52d92a9433a19dd9fcd473bac2eee | ||
secrets: inherit |
Oops, something went wrong.