Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: improve workflow actions #14

Merged
merged 11 commits into from
Feb 18, 2024
4 changes: 2 additions & 2 deletions .github/workflows/add-pull-request-to-project.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Add Pull Request To Project
on:
pull_request:
types: [opened, reopened, labeled]
pull_request_target:
types: [opened, reopened]
workflow_call:
secrets:
ADD_TO_PROJECT_PAT:
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/conventional-label.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
name: 🏷 Label PR

on:
pull_request_target:
types:
- opened
- reopened
- edited
- synchronize

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

on:
pull_request:
types: [opened, reopened]

permissions:
contents: read
pull-requests: write

jobs:
label:
if: github.event.pull_request.labels.length == 0
if: github.event.pull_request.labels[0] == null
runs-on: ubuntu-latest
steps:
- name: "Confirm correct pull request title"
uses: mmubeen/action-pr-title@master # until PR gets merged https://github.com/deepakputhraya/action-pr-title/pull/29
with:
allowed_prefixes: 'feat,fix,build,ci,refactor,test,style,translation,docs,revert'

- name: Generate token
uses: tibdex/[email protected]
id: generate_token
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-closed.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
name: Pull resquest closed
on:
pull_request:
pull_request_target:
types:
- closed

Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/pull_request_check_title.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Validate PR title

on:
pull_request:
pull_request_target:
types:
- opened
- reopened
Expand Down Expand Up @@ -50,12 +50,6 @@ jobs:

Current summary:
"{subject}"
# If the PR only contains a single commit, the action will validate that
# it matches the configured pattern.
validateSingleCommit: true
# Related to `validateSingleCommit` you can opt-in to validate that the PR
# title matches a single commit to avoid confusion.
validateSingleCommitMatchesPrTitle: true

- uses: marocchino/[email protected]
# When the previous steps fails, the workflow would stop. By adding this
Expand Down
23 changes: 20 additions & 3 deletions .github/workflows/validate_pull_request_labels.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
name: "Pull Request Labels Validation"

on:
pull_request:
pull_request_target:
types:
- opened
- synchronize
- reopened
- labeled
- unlabeled


concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
check_pull_request_labels:
name: "Check pull request labels"
Expand All @@ -17,20 +21,33 @@ jobs:
issues: write
pull-requests: write
steps:
- name: Sleep for 15 seconds
run: sleep 15s
shell: bash
- uses: mheap/github-action-required-labels@v5
with:
mode: "exactly"
mode: "minimum"
count: 1
labels: "pull request: breaking,pull request: bug,pull request: community,pull request: dependencies,pull request: documentation,pull request: feature-major,pull request: feature-minor,pull request: maintenance,pull request: skip-changelog,pull request: translation,dependencies"
add_comment: true
message: "This PR is being prevented from merging because you haven't added one of the `pull request:` labels. You'll need to add one of them before this PR can be merged."
- uses: mheap/github-action-required-labels@v5
with:
mode: "maximum"
count: 1
labels: "pull request: breaking,pull request: bug,pull request: dependencies,pull request: documentation,pull request: feature-major,pull request: feature-minor,pull request: maintenance,pull request: translation"
add_comment: true
message: "This PR is being prevented from merging because you have added more than one `pull request:` label. You'll need to keep only one of them before this PR can be merged."
check_issue_labels:
name: "Check issue labels"
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Sleep for 15 seconds
run: sleep 15s
shell: bash
- uses: mheap/github-action-required-labels@v5
with:
mode: "exactly"
Expand Down