From 4b6c1d72f9c67a8dc5cced24a92507918e45e5ed Mon Sep 17 00:00:00 2001 From: Ramiz Polic <32913827+ramizpolic@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:23:39 +0100 Subject: [PATCH] feat: use unified workflows (#6) --- .github/labels.yml | 8 ++-- .../workflows/{_pr_check.yml => _pr-sync.yml} | 41 +++++++++++++------ .github/workflows/_pr_sync.yml | 30 -------------- .../{_stale.yml => _project-sync.yml} | 25 ++++++++++- .github/workflows/_sync.yml | 25 ----------- .github/workflows/pr-sync.yml | 9 +--- .github/workflows/project-sync.yml | 13 ++++++ .github/workflows/sync.yml | 18 -------- 8 files changed, 71 insertions(+), 98 deletions(-) rename .github/workflows/{_pr_check.yml => _pr-sync.yml} (61%) delete mode 100644 .github/workflows/_pr_sync.yml rename .github/workflows/{_stale.yml => _project-sync.yml} (71%) delete mode 100644 .github/workflows/_sync.yml create mode 100644 .github/workflows/project-sync.yml delete mode 100644 .github/workflows/sync.yml diff --git a/.github/labels.yml b/.github/labels.yml index 6778cbe..88a1089 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -30,19 +30,19 @@ - name: 'size/S' color: '77bb02' - description: 'Denotes a PR that changes 10-49 lines' + description: 'Denotes a PR that changes 10-99 lines' - name: 'size/M' color: 'eebb03' - description: 'Denotes a PR that changes 50-99 lines' + description: 'Denotes a PR that changes 100-499 lines' - name: 'size/L' color: 'ee9902' - description: 'Denotes a PR that changes 100-499 lines' + description: 'Denotes a PR that changes 500-999 lines' - name: 'size/XL' color: 'ed5500' - description: 'Denotes a PR that changes 500+ lines' + description: 'Denotes a PR that changes 1000+ lines' # Kind - name: 'kind/design' diff --git a/.github/workflows/_pr_check.yml b/.github/workflows/_pr-sync.yml similarity index 61% rename from .github/workflows/_pr_check.yml rename to .github/workflows/_pr-sync.yml index 78d3b05..3d64310 100644 --- a/.github/workflows/_pr_check.yml +++ b/.github/workflows/_pr-sync.yml @@ -1,16 +1,9 @@ -name: _pr_check +# This action needs works for "pull_request" and "pull_request_target" triggers + +name: _pr-sync on: workflow_call: - inputs: - # New line separated list of valid commit types => type(scope): message - commit-types: - type: string - required: false - # New line separated list of valid commit scopes => type(scope): message - commit-scopes: - type: string - required: false jobs: validate-title: @@ -21,9 +14,6 @@ jobs: id: lint_pr_title env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - types: ${{ inputs.commit-types }} - scopes: ${{ inputs.commit-scopes }} # Leave a comment if linter reports an error - uses: marocchino/sticky-pull-request-comment@v2 @@ -55,3 +45,28 @@ jobs: - uses: Morishiri/block-merge-commits-action@v1.0.1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} + + size-labeler: + runs-on: ubuntu-latest + name: Label size + steps: + - uses: codelytv/pr-size-labeler@v1.7.0 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + xs_label: 'size/XS' + xs_max_size: '10' + s_label: 'size/S' + s_max_size: '100' + m_label: 'size/M' + m_max_size: '500' + l_label: 'size/L' + l_max_size: '1000' + xl_label: 'size/XL' + fail_if_xl: 'false' + message_if_xl: > + This PR exceeds the recommended size of 1000 lines. + Please make sure you are NOT addressing multiple issues with one PR. + Note that this PR might be rejected due to its size. + github_api_url: 'api.github.com' + files_to_ignore: | + "*.md" diff --git a/.github/workflows/_pr_sync.yml b/.github/workflows/_pr_sync.yml deleted file mode 100644 index d71a4fd..0000000 --- a/.github/workflows/_pr_sync.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: _pr_sync - -on: - workflow_call: - -jobs: - pr-labler: - runs-on: ubuntu-latest - name: Label PR size - steps: - - uses: codelytv/pr-size-labeler@v1.7.0 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - xs_label: 'size/XS' - xs_max_size: '10' - s_label: 'size/S' - s_max_size: '50' - m_label: 'size/M' - m_max_size: '100' - l_label: 'size/L' - l_max_size: '500' - xl_label: 'size/XL' - fail_if_xl: 'false' - message_if_xl: > - This PR exceeds the recommended size of 1000 lines. - Please make sure you are NOT addressing multiple issues with one PR. - Note that this PR might be rejected due to its size. - github_api_url: 'api.github.com' - files_to_ignore: | - "*.md" diff --git a/.github/workflows/_stale.yml b/.github/workflows/_project-sync.yml similarity index 71% rename from .github/workflows/_stale.yml rename to .github/workflows/_project-sync.yml index ff5ce1b..8142b2b 100644 --- a/.github/workflows/_stale.yml +++ b/.github/workflows/_project-sync.yml @@ -1,4 +1,6 @@ -name: _stale +# This action works for any trigger + +name: _project-sync on: workflow_call: @@ -22,6 +24,7 @@ on: jobs: stale: + name: Mark stale runs-on: ubuntu-latest steps: - name: 📆 mark stale activity @@ -56,3 +59,23 @@ jobs: This PR has been marked `stale` for ${{ inputs.days-until-close }} days, and is now closed due to inactivity. If this contribution is still relevant, please re-open this PR or file a new one. Thank you! + + labels: + name: Sync project labels + runs-on: ubuntu-latest + steps: + - uses: EndBug/label-sync@v2 + with: + # If you want to use a config file, you can put its path or URL here, multiple files are also allowed (more info in the paragraphs below) + # TODO (@ramizpolic): Enable per-project labels via e.g. .github/labels.yml in workflow_call + config-file: | + https://raw.githubusercontent.com/bank-vaults/.github/main/.github/labels.yml + + # If you want to delete any additional label, set this to true + delete-other-labels: false + + # If you want the action just to show you the preview of the changes, without actually editing the labels, set this to true + dry-run: false + + # You can change the token used to change the labels, this is the default one + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/_sync.yml b/.github/workflows/_sync.yml deleted file mode 100644 index 80439a3..0000000 --- a/.github/workflows/_sync.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: _sync - -on: - workflow_call: - -jobs: - sync: - name: Project labels - runs-on: ubuntu-latest - steps: - - uses: EndBug/label-sync@v2 - with: - # If you want to use a config file, you can put its path or URL here, multiple files are also allowed (more info in the paragraphs below) - # TODO (@ramizpolic): Enable per-project labels via e.g. .github/labels.yml in workflow_call - config-file: | - https://raw.githubusercontent.com/bank-vaults/.github/main/.github/labels.yml - - # If you want to delete any additional label, set this to true - delete-other-labels: false - - # If you want the action just to show you the preview of the changes, without actually editing the labels, set this to true - dry-run: false - - # You can change the token used to change the labels, this is the default one - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pr-sync.yml b/.github/workflows/pr-sync.yml index b1746e2..f84aa6f 100644 --- a/.github/workflows/pr-sync.yml +++ b/.github/workflows/pr-sync.yml @@ -1,4 +1,4 @@ -name: pr-sync +name: PR on: pull_request_target: @@ -9,13 +9,8 @@ on: - synchronize jobs: - check: - uses: ./.github/workflows/_pr_check.yml - permissions: - pull-requests: write - sync: - uses: ./.github/workflows/_pr_sync.yml + uses: ./.github/workflows/_pr-sync.yml permissions: pull-requests: write issues: write diff --git a/.github/workflows/project-sync.yml b/.github/workflows/project-sync.yml new file mode 100644 index 0000000..1936c28 --- /dev/null +++ b/.github/workflows/project-sync.yml @@ -0,0 +1,13 @@ +name: Project + +on: + schedule: + - cron: "0 0 * * 0" + workflow_dispatch: + +jobs: + sync: + uses: ./.github/workflows/_project-sync.yml + permissions: + issues: write + pull-requests: write diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml deleted file mode 100644 index 6c45a1f..0000000 --- a/.github/workflows/sync.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: sync - -on: - schedule: - - cron: "0 0 * * 0" - workflow_dispatch: - -jobs: - mark-stale: - uses: ./.github/workflows/_stale.yml - permissions: - issues: write - pull-requests: write - - sync: - uses: ./.github/workflows/_sync.yml - permissions: - issues: write