mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 07:37:20 +00:00
.gitHub/workflows: validate that the directories exist
This commit is contained in:
parent
3bbf5f5b6a
commit
0183ffa8ea
1 changed files with 22 additions and 1 deletions
23
.github/workflows/validate_pr.yml
vendored
23
.github/workflows/validate_pr.yml
vendored
|
|
@ -1,4 +1,4 @@
|
|||
name: PR Format Validation
|
||||
name: PR Format Validatio
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
|
@ -8,10 +8,15 @@ jobs:
|
|||
validate-pr:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Check PR Title Format
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const prTitle = context.payload.pull_request.title;
|
||||
const titleRegex = /^([\w\s,{}/.]+): .+/;
|
||||
|
||||
|
|
@ -19,5 +24,21 @@ jobs:
|
|||
core.setFailed(`PR title "${prTitle}" does not match required format: directory, ...: description`);
|
||||
return;
|
||||
}
|
||||
|
||||
const match = prTitle.match(titleRegex);
|
||||
const dirPart = match[1];
|
||||
const directories = dirPart.split(',').map(d => d.trim());
|
||||
const missingDirs = [];
|
||||
for (const dir of directories) {
|
||||
const fullPath = path.join(process.env.GITHUB_WORKSPACE, dir);
|
||||
if (!fs.existsSync(fullPath)) {
|
||||
missingDirs.push(dir);
|
||||
}
|
||||
}
|
||||
|
||||
if (missingDirs.length > 0) {
|
||||
core.setFailed(`The following directories in the PR title do not exist: ${missingDirs.join(', ')}`);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('✅ PR title format is valid');
|
||||
|
|
|
|||
Loading…
Reference in a new issue