From 2662dfb8ad87ea4f8b060b68dc89a98bf323dc69 Mon Sep 17 00:00:00 2001 From: Wanjohi <71614375+wanjohiryan@users.noreply.github.com> Date: Thu, 30 May 2024 04:42:28 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(gh):=20Initialize=20github=20w?= =?UTF-8?q?orkflows=20(#1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/CODEOWNERS | 1 + .github/dependabot.yml | 11 +++ .github/labeler.yml | 119 ++++++++++++++++++++++++++ .github/labels.yml | 108 +++++++++++++++++++++++ .github/pull_request_template.md | 3 + .github/release-drafter.yml | 45 ++++++++++ .github/workflows/autolabeller.yml | 93 ++++++++++++++++++++ .github/workflows/labels.yml | 33 +++++++ .github/workflows/release-drafter.yml | 16 ++++ 9 files changed, 429 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/dependabot.yml create mode 100644 .github/labeler.yml create mode 100644 .github/labels.yml create mode 100644 .github/pull_request_template.md create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/autolabeller.yml create mode 100644 .github/workflows/labels.yml create mode 100644 .github/workflows/release-drafter.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..d73852f --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @wanjohiryan \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..efec407 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: 'github-actions' + directory: '/' + schedule: + interval: 'weekly' + labels: + - 'type/build' + ignore: + - dependency-name: "*" + update-types: ["version-update:semver-patch"] \ No newline at end of file diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..f0ad6f3 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,119 @@ +version: 2 +labels: + - label: 'type/chore' + branch: '^chore/.*' + title: '^\s*.*?\schore(?:(.+))?!?:' + + - label: 'type/fix' + branch: '^fix/.*' + title: '^\s*.*?\sfix(?:(.+))?!?:' + + - label: 'type/feat' + branch: '^feat/.*' + title: '^\s*.*?\sfeat(?:(.+))?!?:' + + - label: 'type/breaking' + body: '(?i)breaking.*' + + - label: 'type/docs' + branch: '^docs/.*' + title: '^\s*.*?\sdocs(?:(.+))?!?:' + branch: '^docs/.*' + files: + - '**/*.md$' + - '**/*.mdx$' + + - label: 'type/ci' + branch: '^ci/.*' + title: '^\s*.*?\sci(?:(.+))?!?:' + files: + - '.github/.+' + + - label: 'type/build' + branch: '^dependabot/.*' + title: '^\s*.*?\sbuild(?:(.+))?!?:' + + - label: 'type/perf' + title: '^\s*.*?\sperf(?:(.+))?!?:' + + - label: 'mergeable/false' + mergeable: False + + - label: 'usr/dependabot' + branch: '^dependabot/.*' + authors: + - 'dependabot[bot]' + + - label: 'scope/back-end' + files: + - 'server.Dockerfile' + + - label: 'scope/base' + files: + - 'base.Dockerfile' + + - label: 'scope/ffmpeg' + files: + - 'ffmpeg.Dockerfile' + + - label: 'scope/recorder' + files: + - 'recorder.Dockerfile' + + - label: 'scope/relay' + files: + - 'relay.Dockerfile' + + - label: 'scope/front-end' + files: + - 'apps/www/.+' + + - label: 'pkg/www' + files: + - 'apps/www/.+' + + - label: 'scope/git' + files: + - '**/.gitignore$' + - '.github/.+' + + - label: "size/xs" + size: + below: 10 + exclude-files: ["pnpm-lock.yml","yarn.lock"] + + - label: "size/s" + size: + above: 9 + below: 100 + exclude-files: ["pnpm-lock.yml","yarn.lock"] + + - label: "size/m" + size: + above: 49 + below: 200 + exclude-files: ["pnpm-lock.yml","yarn.lock"] + + - label: "size/l" + size: + above: 199 + below: 500 + exclude-files: ["pnpm-lock.yml","yarn.lock"] + + - label: "size/xl" + size: + above: 499 + below: 1000 + exclude-files: ["pnpm-lock.yml","yarn.lock"] + + - label: "size/xxl" + size: + above: 999 + exclude-files: ["pnpm-lock.yml","yarn.lock"] + + - label: "usr/wanjohi" + authors: ['wanjohiryan'] + + - label: "usr/unknown" + negate: True + authors: ['wanjohiryan','apps/dependabot','dependabot', 'dependabot[bot]'] \ No newline at end of file diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..4e3fc07 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,108 @@ +# Default labels +- name: "type/fix" + color: "B60205" + +- name: "type/build" + color: "6C55D7" + +- name: "type/feat" + color: "0ADE12" + +- name: "type/docs" + color: "891059" + +- name: "type/refactor" + color: "8D44DF" + +- name: "type/revert" + color: "5319e7" + +- name: "type/style" + color: "D71964" + +- name: "type/test" + color: "0B9EE8" + +- name: "type/breaking" + color: "0590CC" + +- name: "type/chore" + color: "B44A63" + +- name: "type/ci" + color: "4FE1A6" + +- name: "type/perf" + color: "4FE1A6" + +- name: "mergeable/false" + color: "B60205" + +- name: "priority/high" + color: "D4E734" + +- name: "priority/mid" + color: "D4E734" + +- name: "priority/low" + color: "D4E734" + +- name: "reg/docker" + color: "5319e7" + +- name: "reg/npm" + color: "5319e7" + +- name: "pkg/www" + color: "5319e7" + +- name: "pkg/lib" + color: "5319e7" + +- name: "pkg/aws" + color: "5319e7" + +- name: "scope/git" + color: "B61B66" + +- name: "scope/infra" + color: "B61B66" + +- name: "scope/front-end" + color: "B61B66" + +- name: "scope/relay" + color: "B61B66" + +- name: "scope/base" + color: "B61B66" + +- name: "scope/back-end" + color: "B61B66" + +- name: "size/xs" + color: "AD4322" + +- name: "size/s" + color: "AD4322" + +- name: "size/m" + color: "AD4322" + +- name: "size/l" + color: "AD4322" + +- name: "size/xl" + color: "AD4322" + +- name: "size/xxl" + color: "AD4322" + +- name: "usr/wanjohi" + color: "09469C" + +- name: "usr/dependabot" + color: "09469C" + +- name: "usr/unknown" + color: "09469C" \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..dad5f89 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,3 @@ +## Description + +**What issue are you solving (or what feature are you adding) and how are you doing it?** \ No newline at end of file diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..4eaae2b --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,45 @@ +name-template: 'v$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' +template: | + # What's Changed + + $CHANGES + + **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION +categories: + - title: '⚠ Breaking Changes' + label: 'type/breaking' + - title: '🚀 New Features' + label: 'type/feat' + - title: '🐜 Bug Fixes' + label: 'type/fix' + - title: '🧰 Maintenance' + label: 'type/chore' + - title: '📖 Documentation' + label: 'type/docs' + - title: '⬆ Version Upgrades' + label: 'type/build' + collapse-after: 10 + - title: 'Other changes' + collapse-after: 10 + +version-resolver: + major: + labels: + - 'type/breaking' + minor: + labels: + - 'type/feat' + patch: + labels: + - 'type/fix' + - 'type/build' + - 'type/docs' + - 'type/chore' + - 'type/refactor' + - 'type/ci' + - 'type/style' + - 'type/test' + +exclude-labels: + - 'skip-changelog' \ No newline at end of file diff --git a/.github/workflows/autolabeller.yml b/.github/workflows/autolabeller.yml new file mode 100644 index 0000000..8e94c5f --- /dev/null +++ b/.github/workflows/autolabeller.yml @@ -0,0 +1,93 @@ +name: Pull request auto-labeller + +on: + pull_request: + types: + - labeled + - opened + - synchronize + - reopened + - ready_for_review + - edited + +concurrency: + group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + validate: + name: Validate PR title + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: amannn/action-semantic-pull-request@cfb60706e18bc85e8aec535e3c577abe8f70378e + id: lint_pr_title + env: + GITHUB_TOKEN: ${{ secrets.GIT_MASTER_TOKEN }} + with: + types: |- + build + chore + ci + deprecate + docs + feat + fix + perf + refactor + remove + revert + security + style + test + requireScope: false + # Ensures the subject start with an uppercase character. + subjectPattern: ^([A-Z]).+$ + headerPattern: '^\s*.*?\s(\w*)(?:\(([\w$.\-*/ ]*)\))?: (.*)$' + headerPatternCorrespondence: type, scope, subject + subjectPatternError: | + The subject "{subject}" found in the pull request title "{title}" + didn't match the configured pattern. Please ensure that the subject + starts with an uppercase character + + - uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 + # When the previous steps fails, the workflow would stop. By adding this + # condition you can continue the execution with the populated error message. + if: always() && (steps.lint_pr_title.outputs.error_message != null) + with: + header: pr-title-lint-error + message: | + Hey there and thank you for opening this pull request! 👋🏼 + + We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted. + Additionally, the subject of the title must start with an uppercase character (e.g. feat: New `search` component). + + ``` + ${{ steps.lint_pr_title.outputs.error_message }} + ``` + # Delete a previous comment when the issue has been resolved + - if: ${{ steps.lint_pr_title.outputs.error_message == null }} + uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 + with: + header: pr-title-lint-error + delete: true + + label: + needs: [ validate ] + runs-on: ubuntu-latest + name: Add labels + permissions: + contents: read + pull-requests: write + steps: + - name: Checkout your code + uses: actions/checkout@v4 + + - uses: srvaroa/labeler@v1 + with: + config_path: .github/labeler.yml + use_local_config: true #FIXME: + fail_on_error: true + env: + GITHUB_TOKEN: "${{ secrets.GIT_MASTER_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml new file mode 100644 index 0000000..4a8e373 --- /dev/null +++ b/.github/workflows/labels.yml @@ -0,0 +1,33 @@ +name: GH labels maintainer + +on: + push: + branches: + - 'main' + paths: + - '.github/labels.yml' + - '.github/workflows/labels.yml' + pull_request: + paths: + - '.github/labels.yml' + - '.github/workflows/labels.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + labeler: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Run Labeler + uses: crazy-max/ghaction-github-labeler@v5 + env: + GITHUB_TOKEN: "${{ secrets.GIT_MASTER_TOKEN }}" + with: + dry-run: ${{ github.event_name == 'pull_request' }} + github-token: ${{ secrets.GIT_MASTER_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..0052dc6 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,16 @@ +name: Release drafter + +on: + push: + branches: [ main ] + +jobs: + update_release_draft: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: release-drafter/release-drafter@v6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file