Skip to content

feat!: update workflow #37

feat!: update workflow

feat!: update workflow #37

Workflow file for this run

name: Pull Request
on:
pull_request:
types:
- edited
- opened
- ready_for_review
- reopened
- synchronize
workflow_call:
inputs:
reviewers:
type: string
description: A comma-separated list of reviewers (GitHub usernames) to request a review from.
required: false
team-reviewers:
type: string
description: A comma-separated list of GitHub teams to request a review from.
required: false
jobs:
pull-request:
runs-on: ubuntu-latest
steps:
- id: link-project
name: Link Project
uses: actions/add-to-project@releases/v1
with:
github-token: ${{ secrets.HEDIA_BOT_GITHUB_PAT }}
project-url: https://github.com/orgs/hedia-team/projects/2
- name: Move to In Progress
run: gh project item-edit --id ${{ steps.link-project.outputs.itemId }} --project-id PVT_kwDOAbxhxs4AMUvg --field-id PVTSSF_lADOAbxhxs4AMUvgzgH3I2s --single-select-option-id 47fc9ee4
env:
GH_TOKEN: ${{ secrets.HEDIA_BOT_GITHUB_PAT }}
- if: github.event.pull_request.assignees[0] == null
name: Assign Actor
uses: actions/github-script@v7
with:
github-token: ${{ secrets.HEDIA_BOT_GITHUB_PAT }}
script: |
const owner = "${{ github.repository_owner }}";
const repo = "${{ github.event.repository.name }}";
const issue_number = ${{ github.event.pull_request.number }};
const assignees = ["${{ github.actor }}"];
console.log(`@${owner}/${repo}#${issue_number}: Assigning to ${assignees}`);
await github.rest.issues.addAssignees({ owner, repo, issue_number, assignees });
- if: >
github.event.pull_request.draft == false &&
github.event.pull_request.requested_reviewers[0] == null &&
github.event.pull_request.requested_teams[0] == null
name: Request Reviewers
uses: actions/github-script@v7
with:
github-token: ${{ secrets.HEDIA_BOT_GITHUB_PAT }}
script: |
const owner = "${{ github.repository_owner }}";
const repo = "${{ github.event.repository.name }}";
const pull_number = ${{ github.event.pull_request.number }};
const reviewers = "${{ github.event.inputs.reviewers }}".split(',').filter((reviewer) => reviewer);
const team_reviewers = "${{ github.event.inputs.team-reviewers }}".split(',').filter((reviewer) => reviewer);
console.log(`@${owner}/${repo}#${pull_number}: Requesting review from ${reviewers.concat(team_reviewers)}`);
await github.rest.pulls.requestReviewers({ owner, repo, pull_number, reviewers, team_reviewers });
- name: Set Labels
uses: actions/github-script@v7
with:
github-token: ${{ secrets.HEDIA_BOT_GITHUB_PAT }}
script: |
const owner = "${{ github.repository_owner }}";
const repo = "${{ github.event.repository.name }}";
const issue_number = ${{ github.event.pull_request.number }};
const title = "${{ github.event.pull_request.title }}";
const regex = /^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(?:\((\w+)\))?(!)?: (.+)$/;
console.log(`Checking title "${title}"`);
console.log("For more information: https://www.conventionalcommits.org/en/v1.0.0/");
if (!regex.test(title)) {
throw new Error("Title must follow conventional commit format");
}
const labels = [];
const match = title.match(regex);
switch (match[1]) {
case "feat":
labels.push("feature");
break;
default:
labels.push(match[1]);
break;
}
if (match[3]) {
labels.push("major");
}
else if (labels.includes("feature")) {
labels.push("minor");
}
else {
labels.push("patch");
}
console.log(`@${owner}/${repo}#${issue_number}: Setting labels to ${labels}`);
await github.rest.issues.setLabels({ owner, repo, issue_number, labels });