Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

都内23区を含む主要自治体へのユースクリニックの常設設置 #170

都内23区を含む主要自治体へのユースクリニックの常設設置

都内23区を含む主要自治体へのユースクリニックの常設設置 #170

Workflow file for this run

# Automatically adds labels to issues based on policy categories
name: Add issue tags
on:
issues:
types: [opened]
permissions:
issues: write
contents: read
jobs:
add_label:
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Parse issue content and add labels
id: labeler
uses: actions/github-script@v7
with:
script: |
const issueBody = context.payload.issue.body;
const labelsToAdd = [];
const policyVisionSectionMatch = issueBody.match(/## 政策ビジョン([\s\S]*)## 政策/);
const policyVisionSection = policyVisionSectionMatch ? policyVisionSectionMatch[1] : '';
const categories = [
{ regex: /^経済$/, label: '経済' },
{ regex: /^医療・防災$/, label: '医療・防災' },
{ regex: /^教育・子育て$/, label: '教育・子育て' },
{ regex: /^行政$/, label: '行政' },
{ regex: /^民主主義$/, label: '民主主義' },
{ regex: /^その他$/, label: 'その他' },
];
policyVisionSection.split('\n').forEach(line => {
line.split(', ').forEach(item => {
categories.forEach(category => {
if (category.regex.test(item)) {
console.log(`Match: ${category.label}`);
labelsToAdd.push(category.label);
}
});
});
});
if (labelsToAdd.length > 0) {
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: labelsToAdd
});
}