From aa10490a1e37792d785355fb05503a7246f21f8a Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Thu, 4 Feb 2021 19:05:06 +0300 Subject: [PATCH] Init repo --- .dependabot/config.yml | 41 ++ .editorconfig | 38 + .gitattributes | 147 ++++ .github/CODE_OF_CONDUCT.md | 76 ++ .github/CONTRIBUTING.md | 33 + .github/DEVELOPERS.md | 26 + .github/FUNDING.yml | 6 + .github/ISSUE_TEMPLATE/bug_report.md | 10 + .github/ISSUE_TEMPLATE/docs.md | 10 + .github/ISSUE_TEMPLATE/feature_request.md | 10 + .github/ISSUE_TEMPLATE/question.md | 10 + .github/SECURITY.md | 24 + .github/auto-merge.yml | 23 + .github/auto_assign.yml | 19 + .github/boring-cyborg.yml | 75 ++ .github/card-labeler.yml | 11 + .github/config.yml | 59 ++ .github/dependabot.yml | 57 ++ .github/eslint-disable-bot.yml | 8 + .github/labels.yml | 79 ++ .github/lock.yml | 36 + .github/mergeable.yml | 29 + .github/settings.yml | 163 +++++ .github/stale.yml | 17 + .github/support.yml | 20 + .github/weekly-digest.yml | 7 + .github/workflows/backport.yml | 16 + .github/workflows/broken-links.yml | 28 + .github/workflows/changelog.yml | 41 ++ .../workflows/changelog/configuration.json | 44 ++ .github/workflows/check-urls.yml | 21 + .github/workflows/claim.yml | 42 ++ .github/workflows/cleanup.yml | 15 + .github/workflows/close-pending.yml | 21 + .github/workflows/closing.yml | 32 + .github/workflows/codespell.yaml | 25 + .github/workflows/comment_on_issue.yml | 20 + .github/workflows/commitlint.yml | 17 + .github/workflows/lint/.commitlintrc.json | 5 + .github/workflows/linter.yml | 36 + .github/workflows/lock.yml | 31 + .github/workflows/project-card-moved.yml | 12 + .github/workflows/release-changelog.yml | 39 + .github/workflows/release.yml | 59 ++ .github/workflows/reviewdog.yml | 17 + .github/workflows/spellcheck.yml | 22 + .github/workflows/stale.yml | 25 + .github/workflows/unlock-reopened-issues.yml | 13 + .github/workflows/version-update.yml | 31 + .github/workflows/welcome_contributor.yml | 38 + .gitignore | 38 + .node-inspectorrc | 3 + .prettierignore | 2 + .prettierrc.yaml | 12 + .typo-ci.yml | 41 ++ .vercelignore | 1 + .vimrc | 7 + .whitesource | 8 + LICENSE | 674 ++++++++++++++++++ README.md | 31 + action.yml | 21 + index.js | 28 + jest.config.js | 11 + package.json | 32 + renovate.json | 31 + src/parseEnvironmentName.js | 28 + test/parseEnvironmentName.test.js | 28 + 67 files changed, 2680 insertions(+) create mode 100644 .dependabot/config.yml create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/CODE_OF_CONDUCT.md create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/DEVELOPERS.md create mode 100644 .github/FUNDING.yml create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/docs.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/question.md create mode 100644 .github/SECURITY.md create mode 100644 .github/auto-merge.yml create mode 100644 .github/auto_assign.yml create mode 100644 .github/boring-cyborg.yml create mode 100644 .github/card-labeler.yml create mode 100644 .github/config.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/eslint-disable-bot.yml create mode 100644 .github/labels.yml create mode 100644 .github/lock.yml create mode 100644 .github/mergeable.yml create mode 100644 .github/settings.yml create mode 100644 .github/stale.yml create mode 100644 .github/support.yml create mode 100644 .github/weekly-digest.yml create mode 100644 .github/workflows/backport.yml create mode 100644 .github/workflows/broken-links.yml create mode 100644 .github/workflows/changelog.yml create mode 100644 .github/workflows/changelog/configuration.json create mode 100644 .github/workflows/check-urls.yml create mode 100644 .github/workflows/claim.yml create mode 100644 .github/workflows/cleanup.yml create mode 100644 .github/workflows/close-pending.yml create mode 100644 .github/workflows/closing.yml create mode 100644 .github/workflows/codespell.yaml create mode 100644 .github/workflows/comment_on_issue.yml create mode 100644 .github/workflows/commitlint.yml create mode 100644 .github/workflows/lint/.commitlintrc.json create mode 100644 .github/workflows/linter.yml create mode 100644 .github/workflows/lock.yml create mode 100644 .github/workflows/project-card-moved.yml create mode 100644 .github/workflows/release-changelog.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/reviewdog.yml create mode 100644 .github/workflows/spellcheck.yml create mode 100644 .github/workflows/stale.yml create mode 100644 .github/workflows/unlock-reopened-issues.yml create mode 100644 .github/workflows/version-update.yml create mode 100644 .github/workflows/welcome_contributor.yml create mode 100644 .gitignore create mode 100644 .node-inspectorrc create mode 100644 .prettierignore create mode 100644 .prettierrc.yaml create mode 100644 .typo-ci.yml create mode 100644 .vercelignore create mode 100644 .vimrc create mode 100644 .whitesource create mode 100644 LICENSE create mode 100644 README.md create mode 100644 action.yml create mode 100644 index.js create mode 100644 jest.config.js create mode 100644 package.json create mode 100644 renovate.json create mode 100644 src/parseEnvironmentName.js create mode 100644 test/parseEnvironmentName.test.js diff --git a/.dependabot/config.yml b/.dependabot/config.yml new file mode 100644 index 0000000..3ea4679 --- /dev/null +++ b/.dependabot/config.yml @@ -0,0 +1,41 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +version: 1 + +update_configs: + # Keep package.json (& lockfiles) up to date as soon as + # new versions are published to the npm registry + - package_manager: "javascript" + directory: "/" + update_schedule: "live" + allowed_updates: + - match: + dependency_type: "development" + # Supported dependency types: + # - "development" + # Development dependency group (supported by some package managers) + # - "production" + # Production dependency group (supported by some package managers) + # - "direct" + # Direct/top-level dependencies + # - "indirect" + # Indirect/transient/sub-dependencies + # - "all" + update_type: "all" + # Supported update types: + # - "security" + # - "all" + - match: + dependency_type: "production" + update_type: "security" + + # Keep Dockerfile up to date, batching pull requests weekly + - package_manager: "docker" + directory: "/" + update_schedule: "daily" + + - package_manager: "python" + directory: "/" + update_schedule: "weekly" \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..50dda82 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,38 @@ +# http://editorconfig.org +root = true + +[*] +indent_size = 2 +# Possible values - tab, space +indent_style = space +# Possible values - lf, crlf, cr +end_of_line = lf +# Possible values - latin1, utf-8, utf-16be, utf-16le +charset = utf-8 +insert_final_newline = true +trim_trailing_whitespace = true +max_line_length = 120 + +[*.java] +indent_size = 4 +max_line_length = 100 + +[*.{kt, groovy}] +indent_size = 4 +max_line_length = 100 + +[*.avsc] +indent_size = 4 + +[*.{yml, yaml}] +indent_size = 2 + +[*.{html, xml}] +indent_size = 4 + +[*.{css, scss, json}] +indent_size = 4 + +[*.{md, markdown}] +max_line_length = off +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..100ad4c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,147 @@ +# This file is inspired by https://github.com/alexkaratarakis/gitattributes +# +# Auto detect text files and perform LF normalization +# http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/ +* text=auto +# The above will handle all files NOT found below +# These files are text and should be normalized (Convert crlf => lf) +*.bat text eol=crlf +*.coffee text +*.css text +*.cql text +*.df text +*.ejs text +*.html text +*.java text +*.js text +*.json text +*.less text +*.properties text +*.sass text +*.scss text +*.sh text eol=lf +*.sql text +*.txt text +*.ts text +*.xml text +*.yaml text +*.yml text +# Documents +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain +*.markdown text +*.md text +*.adoc text +*.textile text +*.mustache text +*.csv text +*.tab text +*.tsv text +*.txt text +AUTHORS text +CHANGELOG text +CHANGES text +CONTRIBUTING text +COPYING text +copyright text +*COPYRIGHT* text +INSTALL text +license text +LICENSE text +NEWS text +readme text +*README* text +TODO text +# Graphics +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.tif binary +*.tiff binary +*.ico binary +# SVG treated as an asset (binary) by default. If you want to treat it as text, +# comment-out the following line and uncomment the line after. +*.svg binary +#*.svg text +*.eps binary +# These files are binary and should be left untouched +# (binary is a macro for -text -diff) +*.class binary +*.jar binary +*.war binary +## LINTERS +.csslintrc text +.eslintrc text +.jscsrc text +.jshintrc text +.jshintignore text +.stylelintrc text +## CONFIGS +*.bowerrc text +*.conf text +*.config text +.editorconfig text +.gitattributes text +.gitconfig text +.gitignore text +.htaccess text +*.npmignore text +## HEROKU +Procfile text +.slugignore text +## AUDIO +*.kar binary +*.m4a binary +*.mid binary +*.midi binary +*.mp3 binary +*.ogg binary +*.ra binary +## VIDEO +*.3gpp binary +*.3gp binary +*.as binary +*.asf binary +*.asx binary +*.fla binary +*.flv binary +*.m4v binary +*.mng binary +*.mov binary +*.mp4 binary +*.mpeg binary +*.mpg binary +*.swc binary +*.swf binary +*.webm binary +## ARCHIVES +*.7z binary +*.gz binary +*.rar binary +*.tar binary +*.zip binary +## FONTS +*.ttf binary +*.eot binary +*.otf binary +*.woff binary +*.woff2 binary + +# Always use crlf line endings Gradle .bat file +gradlew.bat text eol=crlf + +# Mark Gradle wrapper as a binary +gradle/wrapper/gradle-wrapper.jar binary + +*.md eol=lf +*.html eol=lf +*.yml eol=lf diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..873b2e3 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at romain.lespinasse@gmail.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..4c5f216 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,33 @@ +# How to contribute to GitHub Slug Action + +## Did you find a bug + +* **Do not open up a GitHub issue if the bug is a security vulnerability**, and instead to refer to our [security policy][1]. + +* **Ensure the bug was not already reported** by searching on GitHub under [Issues][2]. + +* If you're unable to find an open issue addressing the problem, [open a 'Bug' issue][4]. +Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring. + +## Did you write a patch that fixes a bug + +* Open a new GitHub pull request with the patch. + +* Ensure the PR description clearly describes the problem and solution. +Include the relevant issue number if applicable. + +## Do you intend to add a new feature or change an existing one + +* Suggest your change by [opening a 'Feature request' issue][5] and start writing code. + +## Do you have questions about the source code + +* [open an issue][3] with your question. + +Thanks! + +[1]: https://github.com/AlexRogalskiy/github-action-branch-mapper/security/policy +[2]: https://github.com/AlexRogalskiy/github-action-branch-mapper/issues +[3]: https://github.com/AlexRogalskiy/github-action-branch-mapper/issues/new +[4]: https://github.com/AlexRogalskiy/github-action-branch-mapper/issues/new?assignees=&labels=bug&template=bug_report.md&title= +[5]: https://github.com/AlexRogalskiy/github-action-branch-mapper/issues/new?assignees=&labels=enhancement&template=feature_request.md&title= diff --git a/.github/DEVELOPERS.md b/.github/DEVELOPERS.md new file mode 100644 index 0000000..a7d0f44 --- /dev/null +++ b/.github/DEVELOPERS.md @@ -0,0 +1,26 @@ +# Developers guide + +Install the dependencies + +```bash +npm install +``` + +Build the typescript and package it for distribution + +```bash +npm run build && npm run package +``` + +Run the tests + +```bash +$ npm test + + PASS ./index.test.js + βœ“ throws invalid number (3ms) + βœ“ wait 500 ms (504ms) + βœ“ test runs (95ms) + +... +``` diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..6e0908e --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,6 @@ +# These are supported funding model platforms +open_collective: nullables +patreon: AlexRogalskiy +ko_fi: alexrogalskiy +issuehunt: AlexRogalskiy +custom: [ "https://www.nullables.io/" ] diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..25b76d1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,10 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Which version of Kotest are you using** diff --git a/.github/ISSUE_TEMPLATE/docs.md b/.github/ISSUE_TEMPLATE/docs.md new file mode 100644 index 0000000..4d230b8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/docs.md @@ -0,0 +1,10 @@ +--- +name: Documentation request +about: Suggest an improvement to the documentation +title: '' +labels: 'documentation' +assignees: '' + +--- + +Please describe here what you would like to see documented. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..514172d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,10 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: 'enhancement' +assignees: '' + +--- + +**Please describe the feature you'd like to see including any solutions in mind if you have any** diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 0000000..c630090 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,10 @@ +--- +name: Question +about: Questions on kotest usage +title: '' +labels: '' +assignees: '' + +--- + +**Please consider asking your question on our slack channel #kotest or in stack overflow (and tagging with kotest). The github issue tracker is for bugs and feature requests.** diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..531669e --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,24 @@ +# Security Policy + +## Supported Versions and Branches + +| Version | Branch | Supported | +|---------|--------|--------------------| +| 3.x | v3.x | :white_check_mark: | +| 2.x | v2.x | :white_check_mark: | +| 1.1.x | v1.1.x | :x: | +| < 1.x | | :x: | + +A GitHub repository can used one of the available branches as action inside its workflows. + +## Reporting a Vulnerability + +You can report a Vulnerability by [my template](https://github.com/AlexRogalskiy/github-action-branch-mapper/blob/master/.github/ISSUE_TEMPLATE/bug_report.md). + +_Vulnerability stages :_ + +- Reported, +- Confirmed (or declined), +- Fixed on maintained version series. + +After a vulnerability fix, an GitHub issue will be created as document this vulnerability. diff --git a/.github/auto-merge.yml b/.github/auto-merge.yml new file mode 100644 index 0000000..c46356c --- /dev/null +++ b/.github/auto-merge.yml @@ -0,0 +1,23 @@ +# Configuration for probot-auto-merge - https://github.com/bobvanderlinden/probot-auto-merge + +reportStatus: true +updateBranch: true +deleteBranchAfterMerge: true +mergeMethod: squash + +minApprovals: + COLLABORATOR: 0 +maxRequestedChanges: + NONE: 0 +blockingLabels: + - DO NOT MERGE + - WIP + - blocked + +# Will merge whenever the above conditions are met, but also +# the owner has approved or merge label was added. +rules: + - minApprovals: + MEMBER: 3 + - requiredLabels: + - merge diff --git a/.github/auto_assign.yml b/.github/auto_assign.yml new file mode 100644 index 0000000..e663b52 --- /dev/null +++ b/.github/auto_assign.yml @@ -0,0 +1,19 @@ +# Configuration for Auto Assign - https://github.com/kentaro-m/auto-assign + +# Set to true to add reviewers to pull requests +addReviewers: true + +# Set to true to add assignees to pull requests +addAssignees: false + +# A list of reviewers to be added to pull requests (GitHub user name) +reviewers: + - AlexRogalskiy + +# A number of reviewers added to the pull request +# Set 0 to add all the reviewers (default: 0) +numberOfReviewers: 0 + +# A list of keywords to be skipped the process that add reviewers if pull requests include it +skipKeywords: + - wip diff --git a/.github/boring-cyborg.yml b/.github/boring-cyborg.yml new file mode 100644 index 0000000..e5e56a8 --- /dev/null +++ b/.github/boring-cyborg.yml @@ -0,0 +1,75 @@ +# Configure the Boring Cyborg App. Cf.: https://github.com/kaxil/boring-cyborg + +# Let's greet new users! +firstPRWelcomeComment: > + Thank you for opening your first PR! πŸŽ‰ We are very happy and would like + to thank you very much for your contribution. If everything checks out, we'll + make sure to review the PR as soon as possible and give feedback. In the + meantime, to make the reviewing process as fast as possible, you can help us + by checking the following things: + + - Did you follow the JSStandard coding style? + - Did you comment everywhere where the necessity of a piece of code or the + way it was implemented is not immediately obvious? + - Did you attempt to stick as much to current coding habits as possible? + (Note that this does not apply to pieces of code where we ourselves + obviously violated good coding practices, which unfortunately happens + sometimes. But please indicate this in your PR so that we know what you + rectified!) + + Furthermore, make sure that the linter does not complain, which will check + your code on every new commit. If the linter task fails, make sure to run + `yarn lint` locally and check the file `eslint_report.htm` which will tell + you precisely what went wrong. + + Stay sharp, and thanks again! + +# Comment to be posted to congratulate user on their first merged PR +firstPRMergeComment: > + There we go, your PR got merged! Welcome to the party! πŸ”₯ + +# Comment to be posted to on first time issues +firstIssueWelcomeComment: > + Thanks so much for opening up your first issue here on the repository! πŸŽ‰ + We would like to warmly welcome you to the community behind the app! ☺️ + We'll check in soon and have a look at your issue. In the meantime, you can + check your issue and make sure it aligns with our contribution guidelines! + Here's the comprehensive list: + + ## Enhancements + + An enhancement takes a feature and improves or alters its behaviour. Please + make sure to argue how your proposition will aid non-technical text workers, + and why it can't be emulated easily with other features or apps! + + ## Feature requests + + Feature requests introduce whole new features into the app. This requires a + lot of work, so these might be turned down if the implementation costs + supersede the benefits we expect to see from implementing it. Please do not + be disappointed if that happens. It likely has nothing to do with your great + request but simply with us and our missing resources! + + You can of course always ask someone to implement this feature, because a PR + with a working new feature has much higher chances of being merged! :) + + ## Bug reports + + Please note that one of the main reasons for why bug reports cannot be + addressed is that there's not enough information for us to find and fix the + bug you describe, so make sure you try to pinpoint the bug as close as + possible. + + The ideal bug report for us has two qualities: + + 1. The bug is always reproducible, at least within a certain context. + 2. We know exactly what specifically goes wrong, and there is consensus on + what should happen instead. + + Please note that if you encounter behaviour that does not align with your + expectations of what would happen, this might as well be simply intended + behaviour and we need to simply _clarify_ why the behaviour is the way it is. + This is not to be considered a bug and such issues may be closed! Suggest an + enhancement instead! + + But now, have a great day and thank you again! diff --git a/.github/card-labeler.yml b/.github/card-labeler.yml new file mode 100644 index 0000000..aaca295 --- /dev/null +++ b/.github/card-labeler.yml @@ -0,0 +1,11 @@ +Roadmap: + Available: + - 'Status: Available' + Claimed: + - 'Status: Claimed' + In progress: + - 'Status: In Progress' + Done: + - 'Status: Completed' + On Hold: + - 'Status: On Hold' diff --git a/.github/config.yml b/.github/config.yml new file mode 100644 index 0000000..f41e062 --- /dev/null +++ b/.github/config.yml @@ -0,0 +1,59 @@ +# =============================================================================================== # +# https://github.com/behaviorbot/request-info?installation_id=189571 +blank_issues_enabled: false + +# =============================================================================================== # +# Configuration for request-info - https://github.com/behaviorbot/request-info + +requestInfoLabelToAdd: needs-more-info + +requestInfoReplyComment: > + We would appreciate it if you could provide us with more info about this issue/pr! + +# =============================================================================================== # +# Configuration for welcome - https://github.com/behaviorbot/welcome + +newIssueWelcomeComment: > + Thanks for opening your first issue here! πŸŽ‰
+ πŸ‘‰ Be sure to:
+ 1. πŸ“– Have a look at the [Wiki](https://github.com/AlexRogalskiy/github-action-branch-mapper/wiki) and [README](https://github.com/AlexRogalskiy/github-action-branch-mapper/blob/master/README.md) for information
+ 2. πŸ” Search for similar [issues (open and closed)](https://github.com/AlexRogalskiy/github-action-branch-mapper/issues?q=is%3Aissue+)
+ 3. ✍️ Provide enough information to understand, recreate and help out with your problem
+ 4. ℹ️ Let us know if you find a solution and please share it with us
+ 5. πŸ“• Close the issue when your problem has been solved + +newPRWelcomeComment: > + Thanks for opening this pull request! Please check out our contributing guidelines. + +firstPRWelcomeComment: > + **Thanks for opening this pull request!**

Please check check if *Travis* or *Codacy* found any issues with your PR. Also make sure your commits are signed, and that you applied [Code style](https://github.com/AlexRogalskiy/github-action-branch-mapper/issues) and [formatting](.editorconfig).

A maintainer will add an `is:priority` label to your PR if it is up for compensation. + +firstPRMergeComment: > + ** Congrats on merging your first pull request!**

Be sure to follow the issue template. Your issue will be reviewed by a maintainer and labeled for further action. + +firstIssueWelcomeComment: > + **Thanks for opening your first issue here!**

Be sure to follow the issue template. Your issue will be reviewed by a maintainer and labeled for further action. + +# =============================================================================================== # +# Configuration for sentiment-bot - https://github.com/behaviorbot/sentiment-bot + +# *Required* toxicity threshold between 0 and .99 with the higher numbers being the most toxic +# Anything higher than this threshold will be marked as toxic and commented on +sentimentBotToxicityThreshold: .7 + +# *Required* Comment to reply with +sentimentBotReplyComment: > + Please be sure to review the code of conduct and be respectful of other users. + +# =============================================================================================== # +lockThreads: + toxicityThreshold: .7 + numComments: 2 + setTimeInHours: 72 + replyComment: > + This thread is being locked due to exceeding the toxicity minimums. + +# =============================================================================================== # +# Configuration for todo-bot - https://github.com/JasonEtco/todo +todo: + label: 'πŸ—’ To-Do' diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..c9d9fe4 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,57 @@ +version: 2 + +updates: + - package-ecosystem: "github-actions" + open-pull-requests-limit: 5 + directory: "/" + schedule: + interval: "daily" + time: "13:00" + allow: + - dependency-type: direct + commit-message: + prefix: "github-actions" + labels: + - "dependencies" + - ":robot: bot" + assignees: + - "AlexRogalskiy" + reviewers: + - "octocat" + - "AlexRogalskiy" + + # Maintain dependencies for npm + - package-ecosystem: "npm" + open-pull-requests-limit: 10 + directory: "/" + schedule: + interval: "daily" + time: "09:00" + commit-message: + # Prefix all commit messages with "npm" + prefix: "npm" + # Specify labels for npm pull requests + labels: + - "npm" + - "dependencies" + pull-request-branch-name: + # Separate sections of the branch name with a hyphen + # for example, `dependabot-npm_and_yarn-next_js-acorn-6.4.1` + separator: "-" + + - package-ecosystem: "pip" + open-pull-requests-limit: 10 + directory: "/" + schedule: + interval: "daily" + time: "16:00" + commit-message: + prefix: "pip prod" + prefix-development: "pip dev" + include: "scope" + allow: + # Allow both direct and indirect updates for all packages + - dependency-type: "all" + # Labels on pull requests for version updates only + labels: + - "pip dependencies" \ No newline at end of file diff --git a/.github/eslint-disable-bot.yml b/.github/eslint-disable-bot.yml new file mode 100644 index 0000000..bc4121e --- /dev/null +++ b/.github/eslint-disable-bot.yml @@ -0,0 +1,8 @@ +# Configuration for ESLint Disable Watcher - https://github.com/koddsson/eslint-disable-probot + +# Change this to set the number of comments the watcher should comment on a given PR. +commentLimit: 10 +# The message the bot will post on any lines containing a eslint disable comment. +commentMessage: "Please don't disable eslint rules :pray:" +# A optional regular expression that will match against the branch name and not comment on it if it matches. +skipBranchMatching: null diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..781349e --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,79 @@ +## more info https://github.com/crazy-max/ghaction-github-labeler +- # automerge + name: ":bell: automerge" + color: "8f4fbc" + description: "" +- # bot + name: ":robot: bot" + color: "69cde9" + description: "" +- # bug + name: ":bug: bug" + color: "b60205" + description: "" +- # dependencies + name: ":game_die: dependencies" + color: "0366d6" + description: "" + from_name: "dependencies" +- # documentation + name: ":memo: documentation" + color: "c5def5" + description: "" +- # duplicate + name: ":busts_in_silhouette: duplicate" + color: "cccccc" + description: "" +- # enhancement + name: ":sparkles: enhancement" + color: "0054ca" + description: "" +- # feature request + name: ":bulb: feature request" + color: "0e8a16" + description: "" +- # feedback + name: ":mega: feedback" + color: "03a9f4" + description: "" +- # future maybe + name: ":rocket: future maybe" + color: "fef2c0" + description: "" +- # good first issue + name: ":hatching_chick: good first issue" + color: "7057ff" + description: "" +- # help wanted + name: ":pray: help wanted" + color: "4caf50" + description: "" +- # hold + name: ":hand: hold" + color: "24292f" + description: "" +- # invalid + name: ":no_entry_sign: invalid" + color: "e6e6e6" + description: "" +- # maybe bug + name: ":interrobang: maybe bug" + color: "ff5722" + description: "" +- # needs more info + name: ":thinking: needs more info" + color: "795548" + description: "" +- # question + name: ":question: question" + color: "3f51b5" + description: "" + from_name: "question" +- # upstream + name: ":eyes: upstream" + color: "fbca04" + description: "" +- # wontfix + name: ":coffin: wontfix" + color: "ffffff" + description: "" diff --git a/.github/lock.yml b/.github/lock.yml new file mode 100644 index 0000000..cd80978 --- /dev/null +++ b/.github/lock.yml @@ -0,0 +1,36 @@ +# Configuration for lock-threads - https://github.com/dessant/lock-threads + +# Number of days of inactivity before a closed issue or pull request is locked +daysUntilLock: 60 + +# Skip issues and pull requests created before a given timestamp. Timestamp must +# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable +skipCreatedBefore: false + +# Issues and pull requests with these labels will not be locked. Set to `[]` to disable +exemptLabels: + - backlog + +# Label to add before locking, such as `outdated`. Set to `false` to disable +lockLabel: πŸ”’ Locked + +# Comment to post before locking. Set to `false` to disable +lockComment: > + This thread has been automatically locked because it has not had recent + activity. Please open a new issue for related bugs and link to relevant + comments in this thread. + +# Assign `resolved` as the reason for locking. Set to `false` to disable +setLockReason: true + +# Limit to only `issues` or `pulls` +only: issues + +# Optionally, specify configuration settings just for `issues` or `pulls` +# issues: +# exemptLabels: +# - help-wanted +# lockLabel: outdated + +# pulls: +# daysUntilLock: 30 diff --git a/.github/mergeable.yml b/.github/mergeable.yml new file mode 100644 index 0000000..9b11c2d --- /dev/null +++ b/.github/mergeable.yml @@ -0,0 +1,29 @@ +# Configuration for Mergeable - https://github.com/jusx/mergeable + +version: 2 +mergeable: + - when: pull_request.* + validate: + - do: description + no_empty: + enabled: false + + - do: title + must_exclude: + regex: ^\[WIP\] + + - do: label + # must_include: + # regex: 'change|feat|imp|fix|doc|i18n' + must_exclude: + regex: 'wip|work in progress' + + #- do: project + # no_empty: + # enabled: true + # must_include: + # regex: 'change|feat|imp|fix|doc|loc' + + - do: milestone + no_empty: + enabled: false diff --git a/.github/settings.yml b/.github/settings.yml new file mode 100644 index 0000000..b2fcb35 --- /dev/null +++ b/.github/settings.yml @@ -0,0 +1,163 @@ +# Repository settings set via https://github.com/probot/settings +--- +repository: + description: "github-action-branch-mapper" + homepage: https://github.com/AlexRogalskiy/github-action-branch-mapper + topics: web, documents, visualization + private: false + has_issues: true + has_projects: false + has_wiki: false + has_downloads: false + default_branch: master + allow_squash_merge: true + allow_merge_commit: false + allow_rebase_merge: true + +labels: + # Priority labels + - name: "Priority: Critical" + color: ee0701 + description: "This should be dealt with ASAP. Not fixing this issue would be a serious error." + - name: "Priority: High" + color: b60205 + description: "After critical issues are fixed, these should be dealt with before any further issues." + - name: "Priority: Medium" + color: 0e8a16 + description: "This issue may be useful, and needs some attention." + - name: "Priority: Low" + color: e4ea8a + description: "Nice addition, maybe... someday..." + + # Type labels + - name: "Type: Bug" + color: ee0701 + description: "Inconsistencies or issues which will cause a problem for users or implementors." + - name: "Type: Documentation" + color: 0052cc + description: "Solely about the documentation of the project." + - name: "Type: Enhancement" + color: 1d76db + description: "Enhancement of the code, not introducing new features." + - name: "Type: Feature" + color: 0e8a16 + description: "New features or options." + - name: "Type: Support" + color: 5319e7 + description: "Marks an issue as a support ticket." + - name: "Type: Discussion" + color: d4c5f9 + description: "Marks an issue as a generic discussion ticket." + - name: "Type: Maintenance" + color: 2af79e + description: "Generic maintenance tasks, e.g., package updates." + + # Additional markers + - name: "Security" + color: ee0701 + description: "Marks a security issue that needs to be resolved asap." + - name: "Idea" + color: fef2c0 + description: "Marks an idea, which might be excepted and implemented." + - name: "Incomplete" + color: fef2c0 + description: "Marks a PR or issue that is missing information." + - name: "Pull request" + color: fbca04 + description: "There is an PR opened for this issue." + - name: "Accepted" + color: c2e0c6 + description: "This issue or PR has been accepted." + - name: "Declined" + color: f9d0c4 + description: "This issue or PR has been declined." + - name: "Potential duplicate" + color: e6e6e6 + description: "This issue has been automatically marked as a potential duplicate." + + # Ongoing Status labels + - name: "Status: Triage" + color: fbca04 + description: "This issue needs to be triaged." + - name: "Status: On hold" + color: cccccc + description: "Issue or PR that has been placed on hold for now." + - name: "Status: In progress" + color: fbca04 + description: "Issue is currently being resolved by a developer." + - name: "Status: Stale" + color: fef2c0 + description: "There has not been activity on this issue or PR for quite some time." + - name: "Status: Awaiting response" + color: fef2c0 + description: "Issue or PR awaits response from the creator." + - name: "Status: Blocked" + color: fef2c0 + description: "Progress on this issue is currently not possible." + + # Closing status labels + - name: "Closed: Known limitation" + color: e6e6e6 + description: "Issue is closed, it is a known limitation." + - name: "Closed: Expected behavior" + color: e6e6e6 + description: "Issues is closed, it is expected behavior." + - name: "Closed: Duplicate" + color: e6e6e6 + description: "Issue is closed, duplicate of an existing issue." + - name: "Closed: Invalid" + color: e6e6e6 + description: "Issue is closed, marked as not a valid issue (e.g., an user error)." + - name: "Closed: Wrong repository" + color: e6e6e6 + description: "Issue is closed, was created in the wrong repository." + - name: "Closed: Won't Fix" + color: e6e6e6 + description: "Issue is closed, it won't be fixed." + - name: "Closed: Done" + color: c2e0c6 + description: "Issue closed, work on this issue has been marked complete." + + # Others + - name: "Beginner Friendly" + color: 0e8a16 + description: "Good first issue for people wanting to contribute to the project." + - name: "Help wanted" + color: 0e8a16 + description: "We need some extra helping hands or expertise in order to resolve this." + - name: "Hacktoberfest" + description: "Issues/PRs are participating in the Hacktoberfest" + color: fbca04 + +# Not currently implemented by probot/settings, but manually implemented in script/deploy +branch_protection: + restrictions: null + enforce_admins: false + required_status_checks: + strict: true + contexts: + - "continuous-integration/travis-ci" + required_pull_request_reviews: + require_code_owner_reviews: true + +branches: + - name: master + protection: + required_pull_request_reviews: + # required_approving_review_count: 1 + dismiss_stale_reviews: true + require_code_owner_reviews: true + dismissal_restrictions: + users: [ ] + teams: + - Admins + - Masters + required_status_checks: + strict: false + contexts: [ ] + enforce_admins: false + restrictions: + users: [ ] + teams: + - Admins + - Masters diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..dc90e5a --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,17 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 60 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - security +# Label to use when marking an issue as stale +staleLabel: wontfix +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false diff --git a/.github/support.yml b/.github/support.yml new file mode 100644 index 0000000..aed9f64 --- /dev/null +++ b/.github/support.yml @@ -0,0 +1,20 @@ +# Configuration for Support Requests - https://github.com/dessant/support-requests + +# Label used to mark issues as support requests +supportLabel: "Type: Support" + +# Comment to post on issues marked as support requests. Add a link +# to a support page, or set to `false` to disable +supportComment: > + :wave: We use the issue tracker exclusively for bug reports and feature requests. + However, this issue appears to be a support request. Please use our + support channels to get help with the project. + +# Close issues marked as support requests +close: true + +# Lock issues marked as support requests +lock: false + +# Assign `off-topic` as the reason for locking. Set to `false` to disable +setLockReason: true diff --git a/.github/weekly-digest.yml b/.github/weekly-digest.yml new file mode 100644 index 0000000..fe502fb --- /dev/null +++ b/.github/weekly-digest.yml @@ -0,0 +1,7 @@ +# Configuration for weekly-digest - https://github.com/apps/weekly-digest +publishDay: sun +canPublishIssues: true +canPublishPullRequests: true +canPublishContributors: true +canPublishStargazers: true +canPublishCommits: true diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml new file mode 100644 index 0000000..26801eb --- /dev/null +++ b/.github/workflows/backport.yml @@ -0,0 +1,16 @@ +name: Backport +on: + pull_request: + types: + - closed + - labeled + +jobs: + backport: + runs-on: ubuntu-18.04 + name: Backport + steps: + - name: Backport + uses: tibdex/backport@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/broken-links.yml b/.github/workflows/broken-links.yml new file mode 100644 index 0000000..faf46b8 --- /dev/null +++ b/.github/workflows/broken-links.yml @@ -0,0 +1,28 @@ +name: Check for broken links + +on: [ push, pull_request ] + +jobs: + broken-link-check: + runs-on: ubuntu-latest + name: Check for broken links in readme.md + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + # Disabling shallow clone for improving relevancy of SonarQube reporting + fetch-depth: 0 + + - name: Prepare git + run: | + git config --global core.autocrlf false + git config --global core.ignorecase false + git config --global help.autocorrect 1 + git config --global core.fileMode false + + - uses: actions/setup-node@v2.1.4 + with: + node-version: 12.x + + - run: npm install -g markdown-link-check + - run: find . -name \*.md -exec markdown-link-check -c .broken-link-config.json {} \; diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000..89b58d0 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,41 @@ +# From: https://github.com/hopsoft/stimulus_reflex/blob/master/.github/workflows/changelog.yml +name: Changelog + +on: + workflow_dispatch: + release: + types: [ created ] + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 4 + if: "!contains(github.event.head_commit.message, '[nodoc]')" + steps: + - uses: actions/checkout@master + - name: Set up Ruby 3.0 + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.0 + - uses: actions/cache@v2 + with: + path: vendor/bundle + key: ${{ runner.os }}-changelog-gem + restore-keys: ${{ runner.os }}-changelog-gem + - name: Create local changes + run: | + gem install github_changelog_generator + github_changelog_generator -u ${{ github.repository_owner }} -p ${{ github.event.repository.name }} --token ${{ secrets.GITHUB_TOKEN }} --exclude-labels duplicate,question,invalid,wontfix,nodoc + - name: Commit files + run: | + git config --local user.email "github-actions@example.com" + git config --local user.name "GitHub Actions" + git commit -am "[nodoc] Update Changelog\n\nAdded CHANGELOG file" || echo "No changes to commit" + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} \ No newline at end of file diff --git a/.github/workflows/changelog/configuration.json b/.github/workflows/changelog/configuration.json new file mode 100644 index 0000000..cb387bc --- /dev/null +++ b/.github/workflows/changelog/configuration.json @@ -0,0 +1,44 @@ +{ + "categories": [ + { + "title": "## πŸš€ Features", + "labels": [ + "feature" + ] + }, + { + "title": "## πŸ› Fixes", + "labels": [ + "fix" + ] + }, + { + "title": "## πŸ§ͺ Tests", + "labels": [ + "test" + ] + } + ], + "ignore_labels": [ + "ignore" + ], + "sort": "ASC", + "template": "${{CHANGELOG}}\n\n
\nUncategorized\n\n${{UNCATEGORIZED}}\n
", + "pr_template": "- ${{TITLE}}\n - PR: #${{NUMBER}}", + "empty_template": "- no changes", + "transformers": [ + { + "pattern": "[\\-\\*] (\\[(...|TEST|CI|SKIP)\\])( )?(.+?)\n(.+?[\\-\\*] )(.+)", + "target": "- $4\n - $6" + } + ], + "max_tags_to_fetch": 200, + "max_pull_requests": 200, + "max_back_track_time_days": 365, + "exclude_merge_branches": [ + "Owner/qa" + ], + "tag_resolver": { + "method": "semver" + } +} diff --git a/.github/workflows/check-urls.yml b/.github/workflows/check-urls.yml new file mode 100644 index 0000000..98e5d0e --- /dev/null +++ b/.github/workflows/check-urls.yml @@ -0,0 +1,21 @@ +name: Check URLs from changed files + +on: [ push, pull_request ] + +jobs: + job: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: trilom/file-changes-action@v1.2.4 + id: file_changes + with: + output: '' + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.4.1 + - run: gem install awesome_bot + - run: for i in ${{ steps.file_changes.outputs.files_modified }}; do echo; echo "processing $i"; awesome_bot $i --allow-redirect --allow-dupe --allow-ssl || true; done + - uses: actions/upload-artifact@v2 + with: + path: ${{ github.workspace }}/*.json diff --git a/.github/workflows/claim.yml b/.github/workflows/claim.yml new file mode 100644 index 0000000..67430c9 --- /dev/null +++ b/.github/workflows/claim.yml @@ -0,0 +1,42 @@ +name: Claim Issue + +on: + issue_comment: + types: [created] + +jobs: + assign: + name: Update labels and Assign + if: github.event.issue.pull_request == '' + && contains(github.event.comment.body, '/claim') + && contains(toJson(github.event.issue.labels), 'Available') + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v3.1 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + await github.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['Status: Claimed'] + }) + await github.issues.removeLabel({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + name: 'Status: Available' + }) + await github.issues.addAssignees({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + assignees: [context.payload.sender.login] + }) + await github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Thank you @'+context.payload.sender.login+' for claiming this issue! πŸŽ‰ \n\nPlease reference this issue when you submit your Pull Request and make sure you follow the [contributing guidelines](https://github.com/AlexRogalskiy/github-action-branch-mapper/blob/master/.github/CONTRIBUTING.md).' + }) diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml new file mode 100644 index 0000000..abfd978 --- /dev/null +++ b/.github/workflows/cleanup.yml @@ -0,0 +1,15 @@ +name: Clean artifacts + +on: + schedule: + - cron: '0 0 * * *' + +jobs: + clean: + runs-on: ubuntu-latest + steps: + - name: cleanup + uses: kolpav/purge-artifacts-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + expire-in: 14days # all artifacts at least 14 days old diff --git a/.github/workflows/close-pending.yml b/.github/workflows/close-pending.yml new file mode 100644 index 0000000..39e7da2 --- /dev/null +++ b/.github/workflows/close-pending.yml @@ -0,0 +1,21 @@ +name: close-prs + +on: + schedule: + ## https://crontab.guru/examples.html + # Every day + - cron: '0 1 * * *' + +jobs: + close-pending: + name: close-pending + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@master + + - name: Execute close-pending script + if: github.repository == 'AlexRogalskiy/github-action-branch-mapper' + run: ./.github/scripts/close-pending.sh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/closing.yml b/.github/workflows/closing.yml new file mode 100644 index 0000000..adf1332 --- /dev/null +++ b/.github/workflows/closing.yml @@ -0,0 +1,32 @@ +# This file is maintained in https://github.com/WeblateOrg/meta/ +name: Issue closed + +on: + issues: + types: [ closed ] + +jobs: + issueClosed: + runs-on: ubuntu-18.04 + steps: + - name: Add closed question comment + uses: peter-evans/create-or-update-comment@v1 + if: (contains(github.event.issue.labels.*.name, 'question') && ! contains(github.event.issue.labels.*.name, 'wontfix')) || join(github.event.issue.labels.*.name) == '' + with: + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + body: | + The issue you have reported is resolved now. If you don’t feel it’s right, please follow it’s labels to get a clue and take further steps. + * In case you see a similar problem, please open a separate issue. + * If you are happy with the outcome, don’t hesitate to support Weblate by making a [donation](https://ko-fi.com/alexrogalskiy). + - name: Add closed issue comment + uses: peter-evans/create-or-update-comment@v1 + if: "! contains(github.event.issue.labels.*.name, 'invalid') && ! contains(github.event.issue.labels.*.name, 'question') && ! contains(github.event.issue.labels.*.name, 'wontfix') && ! contains(github.event.issue.labels.*.name, 'duplicate') && ! contains(github.event.issue.labels.*.name, 'undecided') && ! contains(github.event.issue.labels.*.name, 'needinfo') && join(github.event.issue.labels.*.name) != ''" + with: + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + body: | + Thank you for your report, the issue you have reported has just been fixed. + * In case you see a problem with the fix, please comment on this issue. + * In case you see a similar problem, please open a separate issue. + * If you are happy with the outcome, don’t hesitate to support Weblate by making a [donation](https://ko-fi.com/alexrogalskiy). diff --git a/.github/workflows/codespell.yaml b/.github/workflows/codespell.yaml new file mode 100644 index 0000000..33372cf --- /dev/null +++ b/.github/workflows/codespell.yaml @@ -0,0 +1,25 @@ +name: Codespell + +on: + push: + tags: + - v* + branches: + - master + pull_request: + branches: + - "master" + +jobs: + codespell: + name: codespell + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: codespell + uses: codespell-project/actions-codespell@master + with: + skip: .git,*.png,*.jpg,*.svg,*.sum + ignore_words_list: aks,keyserver,atleast,dne,ser,ist,files',ba,dum,iam,te,parm + check_filenames: true + check_hidden: true diff --git a/.github/workflows/comment_on_issue.yml b/.github/workflows/comment_on_issue.yml new file mode 100644 index 0000000..3cd9e15 --- /dev/null +++ b/.github/workflows/comment_on_issue.yml @@ -0,0 +1,20 @@ +name: Comment on an issue + +on: + issues: + types: [ opened ] + +jobs: + comment: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v3.1 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'πŸ‘‹ Thanks for reporting!' + }) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml new file mode 100644 index 0000000..98b5558 --- /dev/null +++ b/.github/workflows/commitlint.yml @@ -0,0 +1,17 @@ +name: Commitlint + +on: [ push, pull_request ] + +jobs: + lint: + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: wagoid/commitlint-github-action@v2.1.7 + with: + configFile: './.github/workflows/lint/.commitlintrc.json' + helpURL: https://rook.io/docs/rook/master/development-flow.html#commit-structure diff --git a/.github/workflows/lint/.commitlintrc.json b/.github/workflows/lint/.commitlintrc.json new file mode 100644 index 0000000..b0a9726 --- /dev/null +++ b/.github/workflows/lint/.commitlintrc.json @@ -0,0 +1,5 @@ +{ + "extends": [ + "@commitlint/config-conventional" + ] +} diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..b10a5b2 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,36 @@ +name: Lint Code Base + +# +# Documentation: +# https://help.github.com/en/articles/workflow-syntax-for-github-actions +# + +############################# +# Start the job on all push # +############################# +on: + push: + branches: [ master ] + # Remove the line above to run when pushing to master + pull_request: + branches: [ master ] +############### +# Set the Job # +############### +jobs: + build: + # Name the Job + name: Lint Code Base + # Set the agent to run on + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Lint Code Base + uses: github/super-linter@v3 + env: + VALIDATE_ALL_CODEBASE: false + DEFAULT_BRANCH: master + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml new file mode 100644 index 0000000..5d56a73 --- /dev/null +++ b/.github/workflows/lock.yml @@ -0,0 +1,31 @@ +# From https://github.com/marketplace/actions/lock-threads +name: Lock threads + +on: + schedule: + - cron: '10 5 * * 2' + +jobs: + lock: + runs-on: ubuntu-latest + steps: + - uses: dessant/lock-threads@v2.0.3 + with: + github-token: ${{ github.token }} + issue-lock-inactive-days: '180' + # issue-exclude-created-before: '' + # issue-exclude-labels: '' + # issue-lock-labels: '' + issue-lock-comment: > + This old thread has been automatically locked. If you think you have + found something related to this, please open a new issue by following + the issue guide (), and link to this + old issue if necessary. + issue-lock-reason: 'resolved' + pr-lock-inactive-days: '180' + # pr-exclude-created-before: '' + # pr-exclude-labels: '' + # pr-lock-labels: '' + # pr-lock-comment: '' + # pr-lock-reason: '' + # process-only: '' diff --git a/.github/workflows/project-card-moved.yml b/.github/workflows/project-card-moved.yml new file mode 100644 index 0000000..090b58c --- /dev/null +++ b/.github/workflows/project-card-moved.yml @@ -0,0 +1,12 @@ +name: Project Card Event + +on: + project_card: + types: [ moved ] + +jobs: + triage: + name: Auto card labeler + runs-on: ubuntu-latest + steps: + - uses: technote-space/auto-card-labeler@v1 diff --git a/.github/workflows/release-changelog.yml b/.github/workflows/release-changelog.yml new file mode 100644 index 0000000..36ac83e --- /dev/null +++ b/.github/workflows/release-changelog.yml @@ -0,0 +1,39 @@ +name: 'Release changelog' + +on: + push: + tags: + - '*' + +jobs: + release: + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - name: Get version from tag + id: tag_name + run: | + echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v} + shell: bash + + - name: Build Changelog + id: github_release + uses: mikepenz/release-changelog-builder-action@main + with: + configuration: ".github/workflows/changelog/configuration.json" + owner: "AlexRogalskiy" + repo: "AlexRogalskiy" + ignorePreReleases: "false" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create Release + uses: actions/create-release@latest + with: + draft: false + prerelease: false + tag_name: ${{ steps.tag_name.outputs.current_version }} + release_name: ${{ steps.tag_name.outputs.current_version }} + body: ${{steps.github_release.outputs.changelog}} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e8b7f8a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,59 @@ +name: release +on: + push: + branches: + - master + tags: + - 'v*.*.*' + pull_request: + types: + - labeled + +jobs: + release: + if: github.event.action != 'labeled' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + # Bump version on merging Pull Requests with specific labels. + # (bump:major,bump:minor,bump:patch) + - id: bumpr + if: "!startsWith(github.ref, 'refs/tags/')" + uses: haya14busa/action-bumpr@v1 + + # Update corresponding major and minor tag. + # e.g. Update v1 and v1.2 when releasing v1.2.3 + - uses: haya14busa/action-update-semver@v1 + if: "!steps.bumpr.outputs.skip" + with: + tag: ${{ steps.bumpr.outputs.next_version }} + + # Get tag name. + - id: tag + uses: haya14busa/action-cond@v1 + with: + cond: "${{ startsWith(github.ref, 'refs/tags/') }}" + if_true: ${{ github.ref }} + if_false: ${{ steps.bumpr.outputs.next_version }} + + # Create release. + - uses: actions/create-release@v1 + if: "steps.tag.outputs.value != ''" + env: + # This token is provided by Actions, you do not need to create your own token + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.tag.outputs.value }} + release_name: Release ${{ steps.tag.outputs.value }} + body: ${{ steps.bumpr.outputs.message }} + draft: false + prerelease: false + + release-check: + if: github.event.action == 'labeled' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Post bumpr status comment + uses: haya14busa/action-bumpr@v1 \ No newline at end of file diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml new file mode 100644 index 0000000..3dff160 --- /dev/null +++ b/.github/workflows/reviewdog.yml @@ -0,0 +1,17 @@ +name: reviewdog + +on: [ pull_request ] + +jobs: + remark-lint: + name: runner / remark-lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: remark-lint + uses: prologic/action-remark-lint@v2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + level: error + fail_on_error: false + reporter: github-pr-check # Change reporter. (Only `github-pr-check` is supported at the moment). diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml new file mode 100644 index 0000000..894644c --- /dev/null +++ b/.github/workflows/spellcheck.yml @@ -0,0 +1,22 @@ +name: Typo CI + +on: + push: + branches-ignore: + - master + +jobs: + spellcheck: + name: Typo CI (GitHub Action) + runs-on: ubuntu-latest + timeout-minutes: 4 + if: "!contains(github.event.head_commit.message, '[ci skip]')" + steps: + - name: TypoCheck + uses: typoci/spellcheck-action@master + # with: + # A license can be purchased via: + # https://gumroad.com/l/MvvBE + # typo_ci_license_key: ${{ secrets.TYPO_CI_LICENSE_KEY }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..7cfc32b --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,25 @@ +name: Stale issues and pull requests + +on: + schedule: + - cron: "0 0 * * *" + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-pr-message: 'This pull request is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.' + stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days' + close-issue-message: "This issue was automatically closed because of being stale. Feel free to open a new one if you still experience this problem." + close-pr-message: "This PR was automatically closed because of being stale." + days-before-stale: 30 + days-before-close: 5 + operations-per-run: 1500 + stale-issue-label: 'no-issue-activity' + stale-pr-label: 'no-pr-activity' + exempt-issue-labels: 'awaiting-approval,work-in-progress' + exempt-pr-labels: 'awaiting-approval,work-in-progress' + only-labels: 'awaiting-feedback,awaiting-answers' diff --git a/.github/workflows/unlock-reopened-issues.yml b/.github/workflows/unlock-reopened-issues.yml new file mode 100644 index 0000000..a34e661 --- /dev/null +++ b/.github/workflows/unlock-reopened-issues.yml @@ -0,0 +1,13 @@ +name: Unlock reopened issue + +on: + issues: + types: [ reopened ] + +jobs: + triage: + runs-on: ubuntu-latest + steps: + - uses: Dunning-Kruger/unlock-issues@v1.1 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/version-update.yml b/.github/workflows/version-update.yml new file mode 100644 index 0000000..27e948b --- /dev/null +++ b/.github/workflows/version-update.yml @@ -0,0 +1,31 @@ +name: Version Update + +on: + push: + tags: + - '*.**' + +jobs: + update-version: + name: Update VERSION + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v2 + with: + ref: master + fetch-depth: 0 + + - name: Edit version.txt + run: echo "VERSION = \"$(git describe --tags `git rev-list --tags --max-count=1`)\"" > version.txt + + - name: Commit update + uses: stefanzweifel/git-auto-commit-action@v4 + with: + branch: master + skip_dirty_check: true + commit_message: "docs: updates on VERSION\n\n Added information on VERSION to repository" + commit_options: '--no-verify --signoff' + commit_user_name: GitHub Bot + commit_user_email: github-actions@nullables.io + commit_author: GitHub Bot diff --git a/.github/workflows/welcome_contributor.yml b/.github/workflows/welcome_contributor.yml new file mode 100644 index 0000000..74cc182 --- /dev/null +++ b/.github/workflows/welcome_contributor.yml @@ -0,0 +1,38 @@ +name: Welcome a first-time contributor + +on: pull_request + +jobs: + welcome: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v3.1 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + // Get a list of all issues created by the PR opener + // See: https://octokit.github.io/rest.js/#pagination + const creator = context.payload.sender.login + const opts = github.issues.listForRepo.endpoint.merge({ + ...context.issue, + creator, + state: 'all' + }) + const issues = await github.paginate(opts) + + for (const issue of issues) { + if (issue.number === context.issue.number) { + continue + } + + if (issue.pull_request) { + return // Creator is already a contributor. + } + } + + await github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Welcome, new contributor!' + }) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..910c0b6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar +package-lock.json +**/.DS_Store + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# Build and temp folders +.settings/ +.idea/ +.reporting/ +bin/ +tmp/ +build/* +packages/ +target/ +log/ +site/ +dist/ +.cache +node_modules +.vercel \ No newline at end of file diff --git a/.node-inspectorrc b/.node-inspectorrc new file mode 100644 index 0000000..ccc5505 --- /dev/null +++ b/.node-inspectorrc @@ -0,0 +1,3 @@ +{ + "save-live-edit": true +} \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..809ffcf --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +data.json +node_modules \ No newline at end of file diff --git a/.prettierrc.yaml b/.prettierrc.yaml new file mode 100644 index 0000000..a760174 --- /dev/null +++ b/.prettierrc.yaml @@ -0,0 +1,12 @@ +printWidth: 110 +tabWidth: 2 +useTabs: false +endOfLine: lf +semi: true +singleQuote: true +quoteProps: 'consistent' +jsxSingleQuote: false +trailingComma: 'es5' +bracketSpacing: true +jsxBracketSameLine: false +arrowParens: 'avoid' \ No newline at end of file diff --git a/.typo-ci.yml b/.typo-ci.yml new file mode 100644 index 0000000..81bd581 --- /dev/null +++ b/.typo-ci.yml @@ -0,0 +1,41 @@ +# This is a sample .typo-ci.yml file, it's used to configure how Typo CI will behave. +# Add it to the root of your project and push it to github. +--- + +# What language dictionaries should it use? By default Typo CI will select 'en' & 'en_GB' +# Currently Typo CI supports: +# de +# en +# en_GB +# es +# fr +# it +# pt +# pt_BR +# tr +dictionaries: + - en + - en_GB + +# Any files/folders we should ignore? +excluded_files: + - "vendor/**/*" + - "node_modules/**/*" + - "*.key" + - "*.enc" + - "*.min.css" + - "*.css.map" + - "*.min.js" + - "*.js.map" + - "*.mk" + - "package-lock.json" + - "yarn.lock" + - "Gemfile.lock" + - ".typo-ci.yml" + +# Any typos we should ignore? +excluded_words: + - typoci + +# Would you like filenames to also be spellchecked? +spellcheck_filenames: true \ No newline at end of file diff --git a/.vercelignore b/.vercelignore new file mode 100644 index 0000000..7255efa --- /dev/null +++ b/.vercelignore @@ -0,0 +1 @@ +yarn.lock \ No newline at end of file diff --git a/.vimrc b/.vimrc new file mode 100644 index 0000000..bb4f902 --- /dev/null +++ b/.vimrc @@ -0,0 +1,7 @@ +set tabstop=2 +set shiftwidth=2 +set softtabstop=2 +set expandtab +set nosmarttab + +set textwidth=80 diff --git a/.whitesource b/.whitesource new file mode 100644 index 0000000..6b6a735 --- /dev/null +++ b/.whitesource @@ -0,0 +1,8 @@ +{ + "checkRunSettings": { + "vulnerableCheckRunConclusionLevel": "failure" + }, + "issueSettings": { + "minSeverityLevel": "LOW" + } +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..116cb30 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# GitHub branch mapper + +[![Actions Status][1]][2] +![GitHub Super-Linter][7] +[![Public workflows that use this action.][3]][4] +[![Licence][5]][6] + +Parses branch name and optionally maps to environment name + +```yml +- uses: alexrogalskiy/github-actions/github-action-branch-mapper@master + with: + github-ref: ${{ github.ref }} + map: ${{ toJSON({ dev: 'staging', production: 'production', '.*': 'sandbox' }) }} +``` + +Outputs: + +- `environment` - environment name + + +Run locally: +- `yarn run_action --action github-ref-to-env --github-ref refs/heads/my/branch-name --map '{ "dev": "staging", ".*": "sandbox" }'` + +[1]: https://github.com/AlexRogalskiy/github-action-branch-mapper/workflows/Build/badge.svg +[2]: https://github.com/AlexRogalskiy/github-action-branch-mapper/actions +[3]: https://img.shields.io/endpoint?url=https%3A%2F%2Fapi-git-master.endbug.vercel.app%2Fapi%2Fgithub-actions%2Fused-by%3Faction%3DAlexRogalskiy%2Fgithub-action-branch-mapper%26badge%3Dtrue +[4]: https://github.com/search?o=desc&q=AlexRogalskiy/github-action-branch-mapper+path%3A.github%2Fworkflows+language%3AYAML&s=&type=Code +[5]: https://img.shields.io/github/license/AlexRogalskiy/github-action-branch-mapper +[6]: https://github.com/AlexRogalskiy/github-action-branch-mapper/blob/v3.x/LICENSE +[7]: https://github.com/AlexRogalskiy/github-action-branch-mapper/workflows/Lint/badge.svg diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..8b8ff89 --- /dev/null +++ b/action.yml @@ -0,0 +1,21 @@ +name: "Branch mapper" +description: "Maps branch name to corresponding environment name" + +inputs: + github-ref: + description: 'Github ref to parse' + required: true + map: + description: 'Env branch mappings' + +outputs: + environment: + description: 'Env branch name' + +runs: + using: "node12" + main: "dist/index.js" + +branding: + icon: 'battery' + color: 'orange' diff --git a/index.js b/index.js new file mode 100644 index 0000000..58084e9 --- /dev/null +++ b/index.js @@ -0,0 +1,28 @@ +const core = require("@actions/core"); +const parseEnvironmentName = require('./src/parseEnvironmentName') + +async function run() { + try { + const githubRef = core.getInput('github-ref', { required: true }); + let map = core.getInput('map') + if (map) { + map = JSON.parse(map) + } + + let env = parseEnvironmentName(githubRef, map) + + if (!env) { + throw new Error('Could not parse environment name') + } + + core.setOutput('environment', env) + } catch (error) { + core.setFailed(error.message); + } +} + +module.exports = run; + +if (require.main === module) { + run(); +} diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..d76a13e --- /dev/null +++ b/jest.config.js @@ -0,0 +1,11 @@ +module.exports = { + clearMocks: true, + moduleFileExtensions: [ 'js', 'ts' ], + testEnvironment: 'node', + testMatch: [ '**/*.test.ts' ], + testRunner: 'jest-circus/runner', + transform: { + '^.+\\.ts$': 'ts-jest' + }, + verbose: true +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..88bda9c --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "github-action-branch-mapper", + "version": "1.0.0", + "description": "Automatically rename current branch reference to corresponding environment name according to provided naming convention mappings", + "main": "index.js", + "author": "Alexander Rogalskiy", + "license": "GPLv3", + "private": true, + "scripts": { + "prepublish": "node_modules\\.bin\\ncc build index.js -m -o dist", + "test": "TZ=utc jest" + }, + "dependencies": { + "@actions/core": "^1.2.6" + }, + "devDependencies": { + "@vercel/ncc": "~>0.23.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/AlexRogalskiy/github-action-branch-mapper.git" + }, + "keywords": [ + "github-actions", + "branch mapping", + "javascript" + ], + "bugs": { + "url": "https://github.com/AlexRogalskiy/github-action-branch-mapper/issues" + }, + "homepage": "https://github.com/AlexRogalskiy/github-action-branch-mapper" +} diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..7469d19 --- /dev/null +++ b/renovate.json @@ -0,0 +1,31 @@ +{ + "extends": [ + "config:base", + ":maintainLockFilesWeekly", + ":prHourlyLimitNone", + ":prConcurrentLimitNone" + ], + "maven": { + "enabled": true + }, + "ignoreUnstable": false, + "schedule": [ + "after 10pm every weekday", + "before 5am every weekday", + "every weekend" + ], + "automerge": true, + "automergeType": "branch", + "major": { + "automerge": false + }, + "masterIssue": true, + "timezone": "Europe/Moscow", + "rangeStrategy": "bump", + "commitMessageAction": "Updates", + "commitMessageTopic": "{{depName}}", + "commitMessagePrefix": ":arrow_up:", + "labels": [ + "npm dependencies" + ] +} diff --git a/src/parseEnvironmentName.js b/src/parseEnvironmentName.js new file mode 100644 index 0000000..874fad9 --- /dev/null +++ b/src/parseEnvironmentName.js @@ -0,0 +1,28 @@ +function parseBranch (ref) { + const regex = /refs\/(heads|tags)\/(\S*)/ + const match = ref.match(regex) + + if (match) { + return match[2] + } +} + +function parseEnvironmentName(githubRef, map) { + let env = parseBranch(githubRef) + + if (map) { + // we intentionally do sort reverse to push capture everything key `.*` to end + const keys = Object.keys(map).sort().reverse(); + const mappedName = keys.find((name) => { + const regex = new RegExp(name) + + return regex.test(env) + }) + + env = map[mappedName] + } + + return env; +} + +module.exports = parseEnvironmentName diff --git a/test/parseEnvironmentName.test.js b/test/parseEnvironmentName.test.js new file mode 100644 index 0000000..37f8bd8 --- /dev/null +++ b/test/parseEnvironmentName.test.js @@ -0,0 +1,28 @@ +const parseEnvironmentName = require('../src/parseEnvironmentName') + +describe('parseEnvironmentName', () => { + it('parses branch name', () => { + expect(parseEnvironmentName('refs/heads/my/branch-name')).toEqual('my/branch-name') + expect(parseEnvironmentName('refs/tags/v-1.12.33')).toEqual('v-1.12.33') + expect(parseEnvironmentName('refs/heads/production')).toEqual('production') + }) + + describe('when branch to env mapping is given', () => { + expect(parseEnvironmentName('refs/heads/my/branch-name', { + "my/branch-name": "sandbox" + })).toEqual('sandbox') + + expect(parseEnvironmentName('refs/heads/my/branch-name', { + ".*": "sandbox" + })).toEqual('sandbox') + + expect(parseEnvironmentName('refs/heads/my/branch-name', { + ".*": "sandbox", + "my/branch-name": "staging" + })).toEqual('staging') + + expect(parseEnvironmentName('refs/heads/no-map-match', { + "my/branch-name": "sandbox" + })).toBeUndefined() + }) +})