mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-01-10 19:05:09 +00:00
Update validate-scripts.yml
This commit is contained in:
parent
02401aa35d
commit
37f4a841a6
38
.github/workflows/validate-scripts.yml
vendored
38
.github/workflows/validate-scripts.yml
vendored
@ -16,6 +16,11 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Debug event payload
|
||||||
|
run: |
|
||||||
|
echo "Event name: ${{ github.event_name }}"
|
||||||
|
echo "Payload: $(cat $GITHUB_EVENT_PATH)"
|
||||||
|
|
||||||
- name: Get pull request information
|
- name: Get pull request information
|
||||||
if: github.event_name == 'pull_request_target'
|
if: github.event_name == 'pull_request_target'
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
@ -31,16 +36,16 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Ensure the full history is fetched for accurate diffing
|
fetch-depth: 0
|
||||||
ref: ${{ github.event_name == 'pull_request_target' && fromJSON(steps.pr.outputs.result).merge_commit_sha || '' }}
|
ref: ${{ github.event_name == 'pull_request_target' && fromJSON(steps.pr.outputs.result).merge_commit_sha || '' }}
|
||||||
|
|
||||||
- name: Get changed files
|
- name: Get changed files
|
||||||
id: changed-files
|
id: changed-files
|
||||||
run: |
|
run: |
|
||||||
if ${{ github.event_name == 'pull_request_target' }}; then
|
if [ "${{ github.event_name }}" == "pull_request_target" ]; then
|
||||||
echo "files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ steps.pr.outputs.result && fromJSON(steps.pr.outputs.result).merge_commit_sha }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
|
echo "files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ steps.pr.outputs.result && fromJSON(steps.pr.outputs.result).merge_commit_sha }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
|
echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Check build.func line
|
- name: Check build.func line
|
||||||
@ -170,12 +175,12 @@ jobs:
|
|||||||
script: |
|
script: |
|
||||||
const result = '${{ job.status }}' === 'success' ? 'success' : 'failure';
|
const result = '${{ job.status }}' === 'success' ? 'success' : 'failure';
|
||||||
const nonCompliantFiles = {
|
const nonCompliantFiles = {
|
||||||
'Invalid build.func source': "${{ steps.build-func.outputs.files }}",
|
'Invalid build.func source': "${{ steps.build-func.outputs.files || '' }}",
|
||||||
'Not executable': "${{ steps.check-executable.outputs.files }}",
|
'Not executable': "${{ steps.check-executable.outputs.files || '' }}",
|
||||||
'Copyright header line missing or invalid': "${{ steps.check-copyright.outputs.files }}",
|
'Copyright header line missing or invalid': "${{ steps.check-copyright.outputs.files || '' }}",
|
||||||
'Author header line missing or invalid': "${{ steps.check-author.outputs.files }}",
|
'Author header line missing or invalid': "${{ steps.check-author.outputs.files || '' }}",
|
||||||
'License header line missing or invalid': "${{ steps.check-license.outputs.files }}",
|
'License header line missing or invalid': "${{ steps.check-license.outputs.files || '' }}",
|
||||||
'Source header line missing or invalid': "${{ steps.check-source.outputs.files }}"
|
'Source header line missing or invalid': "${{ steps.check-source.outputs.files || '' }}"
|
||||||
};
|
};
|
||||||
|
|
||||||
const issueNumber = context.payload.pull_request ? context.payload.pull_request.number : null;
|
const issueNumber = context.payload.pull_request ? context.payload.pull_request.number : null;
|
||||||
@ -205,15 +210,14 @@ jobs:
|
|||||||
issue_number: issueNumber
|
issue_number: issueNumber
|
||||||
});
|
});
|
||||||
|
|
||||||
const existingComment = comments.find(comment => comment.user.login === 'github-actions[bot]');
|
const existingComment = comments.find(comment =>
|
||||||
|
comment.body.includes(`<!-- ${commentIdentifier}-start -->`) &&
|
||||||
|
comment.user.login === 'github-actions[bot]'
|
||||||
|
);
|
||||||
|
|
||||||
if (existingComment) {
|
if (existingComment) {
|
||||||
if (existingComment.body.includes(commentIdentifier)) {
|
const re = new RegExp(String.raw`<!-- ${commentIdentifier}-start -->[\\s\\S]*?<!-- ${commentIdentifier}-end -->`, "m");
|
||||||
const re = new RegExp(String.raw`<!-- ${commentIdentifier}-start -->[\\s\\S]*?<!-- ${commentIdentifier}-end -->`, "");
|
newCommentBody = existingComment.body.replace(re, newCommentBody);
|
||||||
newCommentBody = existingComment.body.replace(re, newCommentBody);
|
|
||||||
} else {
|
|
||||||
newCommentBody = existingComment.body + '\n\n---\n\n' + newCommentBody;
|
|
||||||
}
|
|
||||||
|
|
||||||
await github.rest.issues.updateComment({
|
await github.rest.issues.updateComment({
|
||||||
...context.repo,
|
...context.repo,
|
||||||
|
Loading…
Reference in New Issue
Block a user