forked from forkanization/Proxmox-arm64
Add .github folder
This commit is contained in:
15
.github/CODEOWNERS
vendored
Normal file
15
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#
|
||||||
|
# CODEOWNERS for ProxmoxVE
|
||||||
|
#
|
||||||
|
|
||||||
|
# Order is important; the last matching pattern takes the most
|
||||||
|
# precedence.
|
||||||
|
|
||||||
|
|
||||||
|
# Codeowners for specific folders and files
|
||||||
|
# Remember ending folders with /
|
||||||
|
|
||||||
|
|
||||||
|
# Set default reviewers
|
||||||
|
* @asylumexp
|
||||||
|
|
||||||
12
.github/CONTRIBUTING.md
vendored
12
.github/CONTRIBUTING.md
vendored
@@ -1,14 +1,8 @@
|
|||||||
<div align="center">
|
<div align="center">
|
||||||
<a href="#">
|
<a href="#">
|
||||||
<img src="https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo.png" height="100px" />
|
<img src="https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/images/logo.png" height="100px" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<h2 align="center">Contributing to Proxmox VE Helper Scripts</h2>
|
<h2 align="center">Contributing to Proxmox ARM64 VE Helper Scripts</h2>
|
||||||
|
|
||||||
Everybody is invited and welcome to contribute to Proxmox VE Helper Scripts.
|
This repo does not accept any additions for new scripts. Instead, add them to the community-scripts repo, then they'll be ported to arm64. Other than that, any changes are welcome to be PR'd and I'll review them.
|
||||||
|
|
||||||
- Pull requests submitted against [**main**](https://github.com/tteck/Proxmox/tree/main) are meticulously scrutinized, so please do not take it personally if the project maintainer rejects your request. By adhering to the established patterns and conventions throughout the codebase, you greatly increase the likelihood that your changes will get merged into [**main**](https://github.com/tteck/Proxmox/tree/main).
|
|
||||||
|
|
||||||
- It is important to stress that complaining about a decision after it has been made is not productive behavior for the pull request submitter. It is crucial for all contributors to respect the decision-making process and collaborate effectively towards achieving the best possible outcome for the project.
|
|
||||||
|
|
||||||
- The repository will only accept Alpine applications that make use of the Alpine Package Keeper.
|
|
||||||
|
|||||||
37
.github/DISCUSSION_TEMPLATE/request-script.yml
vendored
Normal file
37
.github/DISCUSSION_TEMPLATE/request-script.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
title: "[Script request] "
|
||||||
|
labels: ["enhancement"]
|
||||||
|
body:
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: Application Name
|
||||||
|
description: Enter the application name.
|
||||||
|
placeholder: "e.g., Home Assistant"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: Website
|
||||||
|
description: Official website or github page.
|
||||||
|
placeholder: "e.g., https://www.home-assistant.io/"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Description
|
||||||
|
description: Explain what the application does and why it should be added to Proxmox VE Helper-Scripts.
|
||||||
|
placeholder: "e.g., Home Assistant is a popular open-source platform that brings all your smart home devices together in one place. Adding it to Proxmox VE Helper-Scripts would make setup and management on Proxmox easy, letting users quickly get a powerful, self-hosted smart home system up and running."
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: checkboxes
|
||||||
|
attributes:
|
||||||
|
label: Due Diligence
|
||||||
|
options:
|
||||||
|
- label: "I have searched existing [scripts](https://community-scripts.github.io/Proxmox/scripts) and found no duplicates."
|
||||||
|
required: true
|
||||||
|
- label: "I have searched existing [discussions](https://github.com/community-scripts/ProxmoxVE/discussions?discussions_q=) and found no duplicate requests."
|
||||||
|
required: true
|
||||||
|
- label: "This is not a game-related request."
|
||||||
|
required: true
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: "Thanks for submitting your request! The team will review it and reach out if we need more information."
|
||||||
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -1 +1 @@
|
|||||||
ko_fi: proxmoxhelperscripts
|
ko_fi: community_scripts
|
||||||
|
|||||||
100
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
100
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
name: "🐞 Script Issue Report"
|
||||||
|
description: Report a specific issue with a script. For other inquiries, please use the Discussions section.
|
||||||
|
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
# 🐞 **Script Issue Report**
|
||||||
|
Thank you for taking the time to report an issue! Please provide as much detail as possible to help us address the problem efficiently.
|
||||||
|
|
||||||
|
## ⚠️ **IMPORTANT**
|
||||||
|
- 🔍 **Search first:** Before submitting, check if the issue has already been reported or resolved in [closed issues](https://github.com/community-scripts/ProxmoxVE/issues?q=is%3Aissue+is%3Aclosed). If found, comment on that issue instead of creating a new one.
|
||||||
|
Alternatively, check the **[Discussions](https://github.com/community-scripts/ProxmoxVE/discussions)** under the *"Announcement"* or *"Guide"* categories for relevant information.
|
||||||
|
- 🛠️ **Supported environments only:** Ensure you are using a default Linux distribution. Custom setups may not be supported.
|
||||||
|
- 🔎 If you encounter `[ERROR] in line 23: exit code *: while executing command "$@" > /dev/null 2>&1`, rerun the script with verbose mode before submitting the issue.
|
||||||
|
- 💡 For general questions, feature requests, or suggestions, use the [Discussions section](https://github.com/community-scripts/ProxmoxVE/discussions).
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: guidelines
|
||||||
|
attributes:
|
||||||
|
label: ✅ Have you read and understood the above guidelines?
|
||||||
|
placeholder: "yes"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: script_name
|
||||||
|
attributes:
|
||||||
|
label: 📜 What is the name of the script you are using?
|
||||||
|
placeholder: "e.g., NextcloudPi, Zigbee2MQTT"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: script_command
|
||||||
|
attributes:
|
||||||
|
label: 📂 What was the exact command used to execute the script?
|
||||||
|
placeholder: "e.g., bash -c \"$(wget -qLO - https://github.com/community-scripts/ProxmoxVE/raw/main/ct/zigbee2mqtt.sh)\" or \"update\""
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: issue_description
|
||||||
|
attributes:
|
||||||
|
label: 📝 Provide a clear and concise description of the issue.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: checkboxes
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
attributes:
|
||||||
|
label: ⚙️ What settings are you using?
|
||||||
|
options:
|
||||||
|
- label: Default Settings
|
||||||
|
- label: Advanced Settings
|
||||||
|
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: "💡 **Tip:** If you are using Advanced Settings, please test with Default Settings before submitting an issue."
|
||||||
|
|
||||||
|
- type: dropdown
|
||||||
|
id: linux_distribution
|
||||||
|
attributes:
|
||||||
|
label: 🖥️ Which Linux distribution are you using?
|
||||||
|
options:
|
||||||
|
-
|
||||||
|
- Alpine
|
||||||
|
- Debian 11
|
||||||
|
- Debian 12
|
||||||
|
- Ubuntu 20.04
|
||||||
|
- Ubuntu 22.04
|
||||||
|
- Ubuntu 24.04
|
||||||
|
- Ubuntu 24.10
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: steps_to_reproduce
|
||||||
|
attributes:
|
||||||
|
label: 🔄 Steps to reproduce the issue.
|
||||||
|
placeholder: "e.g., Step 1: ..., Step 2: ..."
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: error_output
|
||||||
|
attributes:
|
||||||
|
label: ❌ Paste the full error output (if available).
|
||||||
|
placeholder: "Include any relevant logs or error messages."
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: additional_context
|
||||||
|
attributes:
|
||||||
|
label: 🖼️ Additional context (optional).
|
||||||
|
placeholder: "Include screenshots, code blocks (use triple backticks ```), or any other relevant information."
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
12
.github/ISSUE_TEMPLATE/config.yml
vendored
12
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,5 +1,11 @@
|
|||||||
blank_issues_enabled: false
|
blank_issues_enabled: false
|
||||||
contact_links:
|
contact_links:
|
||||||
- name: Helper-Scripts Community Support
|
- name: 🤔 Questions and Help
|
||||||
url: https://github.com/tteck/Proxmox/discussions
|
url: https://github.com/community-scripts/ProxmoxVE/discussions
|
||||||
about: Please ask and answer questions here.
|
about: For suggestions or questions, please use the Discussions section.
|
||||||
|
- name: 🌟 Feature request
|
||||||
|
url: https://github.com/community-scripts/ProxmoxVE/discussions/new?category=request-script
|
||||||
|
about: For feature/script requests, please use the Discussions section.
|
||||||
|
- name: 💻 Discord
|
||||||
|
url: https://discord.gg/UHrpNWGwkH
|
||||||
|
about: Join our Discord server to chat with other users in the Proxmox Helper Scripts community.
|
||||||
|
|||||||
75
.github/ISSUE_TEMPLATE/frontend_report.yml
vendored
Normal file
75
.github/ISSUE_TEMPLATE/frontend_report.yml
vendored
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
name: "🌐 Website Issue Report"
|
||||||
|
description: Report an issue, an optimization request or an documentation issue specifically related to the website.
|
||||||
|
labels: "website"
|
||||||
|
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
**IMPORTANT:** Failure to comply with the following guidelines may result in immediate closure.
|
||||||
|
- Prior to submitting, kindly search the closed issues to check if the problem you are reporting has already been addressed and resolved. If you come across a closed issue that pertains to your problem, please leave a comment on that issue instead of creating a new one.
|
||||||
|
- If the problem is related to a bug in the website, kindly check for browser compatibility and ensure the issue occurs in multiple browsers before submitting.
|
||||||
|
- For suggestions, questions, or feature requests, please use the [Discussions section.](https://github.com/community-scripts/ProxmoxVE/discussions)
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: guidelines
|
||||||
|
attributes:
|
||||||
|
label: Please verify that you have read and understood the guidelines.
|
||||||
|
placeholder: 'yes'
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: dropdown
|
||||||
|
id: issue_type
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
attributes:
|
||||||
|
label: What type of issue is this?
|
||||||
|
options:
|
||||||
|
-
|
||||||
|
- Bug
|
||||||
|
- Optimization
|
||||||
|
- Documentation
|
||||||
|
- Other
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: bug_description
|
||||||
|
attributes:
|
||||||
|
label: A clear and concise description of the issue.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: dropdown
|
||||||
|
id: browser
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
attributes:
|
||||||
|
label: Which browser are you using?
|
||||||
|
options:
|
||||||
|
-
|
||||||
|
- Chrome
|
||||||
|
- Firefox
|
||||||
|
- Safari
|
||||||
|
- Edge
|
||||||
|
- Other
|
||||||
|
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
**If the issue is browser-related**, please provide information on the version and platform (Windows, MacOS, Linux, etc.).
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: screenshot
|
||||||
|
attributes:
|
||||||
|
label: If relevant, including screenshots or a code block can be helpful in clarifying the issue.
|
||||||
|
placeholder: "Code blocks begin and conclude by enclosing the code with three backticks (```) above and below it."
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: reproduce
|
||||||
|
attributes:
|
||||||
|
label: Please provide detailed steps to reproduce the issue.
|
||||||
|
placeholder: "First do this, then this ..."
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
64
.github/autolabeler-config.json
vendored
Normal file
64
.github/autolabeler-config.json
vendored
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"breaking change": [
|
||||||
|
{
|
||||||
|
"fileStatus": "renamed",
|
||||||
|
"includeGlobs": ["ct/**", "install/**", "misc/**", "turnkey/**", "vm/**"],
|
||||||
|
"excludeGlobs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fileStatus": "removed",
|
||||||
|
"includeGlobs": ["ct/**", "install/**", "misc/**", "turnkey/**", "vm/**"],
|
||||||
|
"excludeGlobs": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"new script": [
|
||||||
|
{
|
||||||
|
"fileStatus": "added",
|
||||||
|
"includeGlobs": ["ct/**", "install/**", "misc/**", "turnkey/**", "vm/**"],
|
||||||
|
"excludeGlobs": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"update script": [
|
||||||
|
{
|
||||||
|
"fileStatus": "modified",
|
||||||
|
"includeGlobs": ["ct/**", "install/**", "misc/**", "turnkey/**", "vm/**"],
|
||||||
|
"excludeGlobs": ["misc/build.func", "misc/install.func"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"delete script": [
|
||||||
|
{
|
||||||
|
"fileStatus": "removed",
|
||||||
|
"includeGlobs": ["ct/**", "install/**", "misc/**", "turnkey/**", "vm/**"],
|
||||||
|
"excludeGlobs": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rename script": [
|
||||||
|
{
|
||||||
|
"fileStatus": "renamed",
|
||||||
|
"includeGlobs": ["ct/**", "install/**", "misc/**", "turnkey/**", "vm/**"],
|
||||||
|
"excludeGlobs": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"website": [
|
||||||
|
{
|
||||||
|
"fileStatus": null,
|
||||||
|
"includeGlobs": ["frontend/**", "json/**"],
|
||||||
|
"excludeGlobs": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"maintenance": [
|
||||||
|
{
|
||||||
|
"fileStatus": null,
|
||||||
|
"includeGlobs": ["*.md", ".github/**"],
|
||||||
|
"excludeGlobs": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"high risk": [
|
||||||
|
{
|
||||||
|
"fileStatus": null,
|
||||||
|
"includeGlobs": ["misc/build.func", "misc/install.func"],
|
||||||
|
"excludeGlobs": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
30
.github/changelog-pr-config.json
vendored
Normal file
30
.github/changelog-pr-config.json
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"title": "💥 Breaking Changes",
|
||||||
|
"labels": ["breaking change"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "✨ New Scripts",
|
||||||
|
"labels": ["new script"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "🚀 Updated Scripts",
|
||||||
|
"labels": ["update script"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "🌐 Website",
|
||||||
|
"labels": ["website"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "🐞 Bug Fixes",
|
||||||
|
"labels": ["bug fix"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "🧰 Maintenance",
|
||||||
|
"labels": ["maintenance"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "❔ Unlabelled",
|
||||||
|
"labels": []
|
||||||
|
}
|
||||||
|
]
|
||||||
9
.github/pull.yml
vendored
9
.github/pull.yml
vendored
@@ -1,9 +0,0 @@
|
|||||||
version: "1"
|
|
||||||
rules:
|
|
||||||
- base: main
|
|
||||||
upstream: tteck:main
|
|
||||||
mergeMethod: merge # [none, merge, squash, rebase, hardreset]
|
|
||||||
conflictReviewers:
|
|
||||||
- asylumexp
|
|
||||||
label: ":arrow_heading_down: pull"
|
|
||||||
conflictLabel: "merge-conflict"
|
|
||||||
39
.github/pull_request_template.md
vendored
Normal file
39
.github/pull_request_template.md
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
> **🛠️ Note:**
|
||||||
|
> We are meticulous about merging code into the main branch, so please understand that pull requests not meeting the project's standards may be rejected. It's never personal!
|
||||||
|
> 🎮 **Note for game-related scripts:** These have a lower likelihood of being merged.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✍️ Description
|
||||||
|
Provide a summary of the changes made and/or reference the issue being addressed.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
- - -
|
||||||
|
**_Please remove unneeded lines!_**
|
||||||
|
- Related Issue: # (issue number, if applicable)
|
||||||
|
- Related PR: # (if applicable)
|
||||||
|
- Related Discussion: []()(if applicable)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🛠️ Type of Change
|
||||||
|
Please check the relevant options:
|
||||||
|
- [ ] Bug fix (non-breaking change that resolves an issue)
|
||||||
|
- [ ] New feature (non-breaking change that adds functionality)
|
||||||
|
- [ ] Breaking change (fix or feature that would cause existing functionality to change unexpectedly)
|
||||||
|
- [ ] New script (a fully functional and thoroughly tested script or set of scripts)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✅ Prerequisites
|
||||||
|
The following steps must be completed for the pull request to be considered:
|
||||||
|
- [ ] Self-review performed (I have reviewed my code to ensure it follows established patterns and conventions.)
|
||||||
|
- [ ] Testing performed (I have thoroughly tested my changes and verified expected functionality.)
|
||||||
|
- [ ] Documentation updated (I have updated any relevant documentation)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📋 Additional Information (optional)
|
||||||
|
Provide any extra context or screenshots about the feature or fix here.
|
||||||
|
|
||||||
78
.github/workflows/frontend-cicd.yml
vendored
Normal file
78
.github/workflows/frontend-cicd.yml
vendored
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
# Based on https://github.com/actions/starter-workflows/blob/main/pages/nextjs.yml
|
||||||
|
|
||||||
|
name: Frontend CI/CD
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
paths:
|
||||||
|
- frontend/**
|
||||||
|
- json/**
|
||||||
|
|
||||||
|
pull_request:
|
||||||
|
branches: ["main"]
|
||||||
|
types: [opened, synchronize, reopened, edited]
|
||||||
|
paths:
|
||||||
|
- frontend/**
|
||||||
|
- json/**
|
||||||
|
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: pages-${{ github.ref }}
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: frontend # Set default working directory for all run steps
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
cache: npm
|
||||||
|
cache-dependency-path: frontend/package-lock.json
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci --prefer-offline --legacy-peer-deps
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: npm run test
|
||||||
|
|
||||||
|
- name: Configure Next.js for pages
|
||||||
|
uses: actions/configure-pages@v5
|
||||||
|
with:
|
||||||
|
static_site_generator: next
|
||||||
|
|
||||||
|
- name: Build with Next.js
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
uses: actions/upload-pages-artifact@v3
|
||||||
|
with:
|
||||||
|
path: frontend/out
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
permissions:
|
||||||
|
pages: write
|
||||||
|
id-token: write
|
||||||
|
environment:
|
||||||
|
name: github-pages
|
||||||
|
url: ${{ steps.deployment.outputs.page_url }}
|
||||||
|
steps:
|
||||||
|
- name: Deploy to GitHub Pages
|
||||||
|
id: deployment
|
||||||
|
uses: actions/deploy-pages@v4
|
||||||
32
.github/workflows/shellcheck.yml
vendored
Normal file
32
.github/workflows/shellcheck.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
name: Shellcheck
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: "5 1 * * *"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
shellcheck:
|
||||||
|
name: Shellcheck
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Get changed files
|
||||||
|
id: changes
|
||||||
|
run: |
|
||||||
|
if ${{ github.event_name == 'pull_request' }}; then
|
||||||
|
echo "files=$(git diff --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Run ShellCheck
|
||||||
|
if: steps.changes.outputs.files != ''
|
||||||
|
run: |
|
||||||
|
echo "${{ steps.changes.outputs.files }}" | xargs shellcheck
|
||||||
157
.github/workflows/validate-filenames.yml
vendored
Normal file
157
.github/workflows/validate-filenames.yml
vendored
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
name: Validate filenames
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
paths:
|
||||||
|
- "ct/*.sh"
|
||||||
|
- "install/*.sh"
|
||||||
|
- "json/*.json"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-files:
|
||||||
|
name: Check changed files
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Get pull request information
|
||||||
|
if: github.event_name == 'pull_request_target'
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
id: pr
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const { data: pullRequest } = await github.rest.pulls.get({
|
||||||
|
...context.repo,
|
||||||
|
pull_number: context.payload.pull_request.number,
|
||||||
|
});
|
||||||
|
return pullRequest;
|
||||||
|
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # Ensure the full history is fetched for accurate diffing
|
||||||
|
ref: ${{ github.event_name == 'pull_request_target' && fromJSON(steps.pr.outputs.result).merge_commit_sha || '' }}
|
||||||
|
|
||||||
|
- name: Get changed files
|
||||||
|
id: changed-files
|
||||||
|
run: |
|
||||||
|
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 }} | xargs)" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: "Validate filenames in ct and install directory"
|
||||||
|
if: always() && steps.changed-files.outputs.files != ''
|
||||||
|
id: check-scripts
|
||||||
|
run: |
|
||||||
|
CHANGED_FILES=$(printf "%s\n" ${{ steps.changed-files.outputs.files }} | { grep -E '^(ct|install)/.*\.sh$' || true; })
|
||||||
|
|
||||||
|
NON_COMPLIANT_FILES=""
|
||||||
|
for FILE in $CHANGED_FILES; do
|
||||||
|
BASENAME=$(echo "$(basename "${FILE%.*}")")
|
||||||
|
if [[ ! "$BASENAME" =~ ^[a-z0-9-]+$ ]]; then
|
||||||
|
NON_COMPLIANT_FILES="$NON_COMPLIANT_FILES $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$NON_COMPLIANT_FILES" ]; then
|
||||||
|
echo "files=$NON_COMPLIANT_FILES" >> $GITHUB_OUTPUT
|
||||||
|
echo "Non-compliant filenames found, change to lowercase:"
|
||||||
|
for FILE in $NON_COMPLIANT_FILES; do
|
||||||
|
echo "$FILE"
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: "Validate filenames in json directory."
|
||||||
|
if: always() && steps.changed-files.outputs.files != ''
|
||||||
|
id: check-json
|
||||||
|
run: |
|
||||||
|
CHANGED_FILES=$(printf "%s\n" ${{ steps.changed-files.outputs.files }} | { grep -E '^json/.*\.json$' || true; })
|
||||||
|
|
||||||
|
NON_COMPLIANT_FILES=""
|
||||||
|
for FILE in $CHANGED_FILES; do
|
||||||
|
BASENAME=$(echo "$(basename "${FILE%.*}")")
|
||||||
|
if [[ ! "$BASENAME" =~ ^[a-z0-9-]+$ ]]; then
|
||||||
|
NON_COMPLIANT_FILES="$NON_COMPLIANT_FILES $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$NON_COMPLIANT_FILES" ]; then
|
||||||
|
echo "files=$NON_COMPLIANT_FILES" >> $GITHUB_OUTPUT
|
||||||
|
echo "Non-compliant filenames found, change to lowercase:"
|
||||||
|
for FILE in $NON_COMPLIANT_FILES; do
|
||||||
|
echo "$FILE"
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Post results and comment
|
||||||
|
if: always() && steps.check-scripts.outputs.files != '' && steps.check-json.outputs.files != '' && github.event_name == 'pull_request_target'
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const result = "${{ job.status }}" === "success" ? "success" : "failure";
|
||||||
|
const nonCompliantFiles = {
|
||||||
|
script: "${{ steps.check-scripts.outputs.files }}",
|
||||||
|
JSON: "${{ steps.check-json.outputs.files }}",
|
||||||
|
};
|
||||||
|
|
||||||
|
const issueNumber = context.payload.pull_request
|
||||||
|
? context.payload.pull_request.number
|
||||||
|
: null;
|
||||||
|
const commentIdentifier = "validate-filenames";
|
||||||
|
let newCommentBody = `<!-- ${commentIdentifier}-start -->\n### Filename validation\n\n`;
|
||||||
|
|
||||||
|
if (result === "failure") {
|
||||||
|
newCommentBody += ":x: We found issues in the following changed files:\n\n";
|
||||||
|
for (const [check, files] of Object.entries(nonCompliantFiles)) {
|
||||||
|
if (files) {
|
||||||
|
newCommentBody += `**${check.charAt(0).toUpperCase() + check.slice(1)} filename invalid:**\n${files
|
||||||
|
.trim()
|
||||||
|
.split(" ")
|
||||||
|
.map((file) => `- ${file}`)
|
||||||
|
.join("\n")}\n\n`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newCommentBody +=
|
||||||
|
"Please change the filenames to lowercase and use only alphanumeric characters and dashes.\n";
|
||||||
|
} else {
|
||||||
|
newCommentBody += `:rocket: All files passed filename validation!\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
newCommentBody += `\n\n<!-- ${commentIdentifier}-end -->`;
|
||||||
|
|
||||||
|
if (issueNumber) {
|
||||||
|
const { data: comments } = await github.rest.issues.listComments({
|
||||||
|
...context.repo,
|
||||||
|
issue_number: issueNumber,
|
||||||
|
});
|
||||||
|
|
||||||
|
const existingComment = comments.find(
|
||||||
|
(comment) => comment.user.login === "github-actions[bot]",
|
||||||
|
);
|
||||||
|
|
||||||
|
if (existingComment) {
|
||||||
|
if (existingComment.body.includes(commentIdentifier)) {
|
||||||
|
const re = new RegExp(String.raw`<!-- ${commentIdentifier}-start -->[\s\S]*?<!-- ${commentIdentifier}-end -->`, "");
|
||||||
|
newCommentBody = existingComment.body.replace(re, newCommentBody);
|
||||||
|
} else {
|
||||||
|
newCommentBody = existingComment.body + '\n\n---\n\n' + newCommentBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
await github.rest.issues.updateComment({
|
||||||
|
...context.repo,
|
||||||
|
comment_id: existingComment.id,
|
||||||
|
body: newCommentBody,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
...context.repo,
|
||||||
|
issue_number: issueNumber,
|
||||||
|
body: newCommentBody,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
130
.github/workflows/validate-formatting.yaml
vendored
Normal file
130
.github/workflows/validate-formatting.yaml
vendored
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
name: Validate script formatting
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request_target:
|
||||||
|
paths:
|
||||||
|
- "**/*.sh"
|
||||||
|
- "**/*.func"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
shfmt:
|
||||||
|
name: Check changed files
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Get pull request information
|
||||||
|
if: github.event_name == 'pull_request_target'
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
id: pr
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const { data: pullRequest } = await github.rest.pulls.get({
|
||||||
|
...context.repo,
|
||||||
|
pull_number: context.payload.pull_request.number,
|
||||||
|
});
|
||||||
|
return pullRequest;
|
||||||
|
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # Ensure the full history is fetched for accurate diffing
|
||||||
|
ref: ${{ github.event_name == 'pull_request_target' && fromJSON(steps.pr.outputs.result).merge_commit_sha || '' }}
|
||||||
|
|
||||||
|
- name: Get changed files
|
||||||
|
id: changed-files
|
||||||
|
run: |
|
||||||
|
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
|
||||||
|
else
|
||||||
|
echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
if: steps.changed-files.outputs.files != ''
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
|
||||||
|
- name: Install shfmt
|
||||||
|
if: steps.changed-files.outputs.files != ''
|
||||||
|
run: |
|
||||||
|
go install mvdan.cc/sh/v3/cmd/shfmt@latest
|
||||||
|
echo "$GOPATH/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
|
- name: Run shfmt
|
||||||
|
if: steps.changed-files.outputs.files != ''
|
||||||
|
id: shfmt
|
||||||
|
run: |
|
||||||
|
set +e
|
||||||
|
|
||||||
|
shfmt_output=$(shfmt -d ${{ steps.changed-files.outputs.files }})
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "diff=\"$(echo -n "$shfmt_output" | base64 -w 0)\"" >> $GITHUB_OUTPUT
|
||||||
|
printf "%s" "$shfmt_output"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Post comment with results
|
||||||
|
if: always() && steps.changed-files.outputs.files != '' && github.event_name == 'pull_request_target'
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const result = "${{ job.status }}" === "success" ? "success" : "failure";
|
||||||
|
const diff = Buffer.from(
|
||||||
|
${{ steps.shfmt.outputs.diff }},
|
||||||
|
"base64",
|
||||||
|
).toString();
|
||||||
|
const issueNumber = context.payload.pull_request
|
||||||
|
? context.payload.pull_request.number
|
||||||
|
: null;
|
||||||
|
const commentIdentifier = "validate-formatting";
|
||||||
|
let newCommentBody = `<!-- ${commentIdentifier}-start -->\n### Script formatting\n\n`;
|
||||||
|
|
||||||
|
if (result === "failure") {
|
||||||
|
newCommentBody +=
|
||||||
|
`:x: We found issues in the formatting of the following changed files:\n\n\`\`\`diff\n${diff}\n\`\`\`\n`;
|
||||||
|
} else {
|
||||||
|
newCommentBody += `:rocket: All changed shell scripts are formatted correctly!\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
newCommentBody += `\n\n<!-- ${commentIdentifier}-end -->`;
|
||||||
|
|
||||||
|
if (issueNumber) {
|
||||||
|
const { data: comments } = await github.rest.issues.listComments({
|
||||||
|
...context.repo,
|
||||||
|
issue_number: issueNumber,
|
||||||
|
});
|
||||||
|
|
||||||
|
const existingComment = comments.find(
|
||||||
|
(comment) => comment.user.login === "github-actions[bot]",
|
||||||
|
);
|
||||||
|
|
||||||
|
if (existingComment) {
|
||||||
|
if (existingComment.body.includes(commentIdentifier)) {
|
||||||
|
const re = new RegExp(
|
||||||
|
String.raw`<!-- ${commentIdentifier}-start -->[\s\S]*?<!-- ${commentIdentifier}-end -->`,
|
||||||
|
"",
|
||||||
|
);
|
||||||
|
newCommentBody = existingComment.body.replace(re, newCommentBody);
|
||||||
|
} else {
|
||||||
|
newCommentBody = existingComment.body + "\n\n---\n\n" + newCommentBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
await github.rest.issues.updateComment({
|
||||||
|
...context.repo,
|
||||||
|
comment_id: existingComment.id,
|
||||||
|
body: newCommentBody,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
...context.repo,
|
||||||
|
issue_number: issueNumber,
|
||||||
|
body: newCommentBody,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
226
.github/workflows/validate-scripts.yml
vendored
Normal file
226
.github/workflows/validate-scripts.yml
vendored
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
name: Validate scripts
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request_target:
|
||||||
|
paths:
|
||||||
|
- "ct/*.sh"
|
||||||
|
- "install/*.sh"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-scripts:
|
||||||
|
name: Check changed files
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Get pull request information
|
||||||
|
if: github.event_name == 'pull_request_target'
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
id: pr
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const { data: pullRequest } = await github.rest.pulls.get({
|
||||||
|
...context.repo,
|
||||||
|
pull_number: context.payload.pull_request.number,
|
||||||
|
});
|
||||||
|
return pullRequest;
|
||||||
|
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # Ensure the full history is fetched for accurate diffing
|
||||||
|
ref: ${{ github.event_name == 'pull_request_target' && fromJSON(steps.pr.outputs.result).merge_commit_sha || '' }}
|
||||||
|
|
||||||
|
- name: Get changed files
|
||||||
|
id: changed-files
|
||||||
|
run: |
|
||||||
|
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 }} | xargs)" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Check build.func line
|
||||||
|
if: always() && steps.changed-files.outputs.files != ''
|
||||||
|
id: build-func
|
||||||
|
run: |
|
||||||
|
NON_COMPLIANT_FILES=""
|
||||||
|
for FILE in ${{ steps.changed-files.outputs.files }}; do
|
||||||
|
if [[ "$FILE" == ct/* ]] && [[ $(sed -n '2p' "$FILE") != "source <(curl -s https://raw.githubusercontent.com/asylumexp/Proxmox/main/misc/build.func)" ]]; then
|
||||||
|
NON_COMPLIANT_FILES="$NON_COMPLIANT_FILES $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$NON_COMPLIANT_FILES" ]; then
|
||||||
|
echo "files=$NON_COMPLIANT_FILES" >> $GITHUB_OUTPUT
|
||||||
|
echo "Build.func line missing or incorrect in files:"
|
||||||
|
for FILE in $NON_COMPLIANT_FILES; do
|
||||||
|
echo "$FILE"
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Check executable permissions
|
||||||
|
if: always() && steps.changed-files.outputs.files != ''
|
||||||
|
id: check-executable
|
||||||
|
run: |
|
||||||
|
NON_COMPLIANT_FILES=""
|
||||||
|
for FILE in ${{ steps.changed-files.outputs.files }}; do
|
||||||
|
if [[ ! -x "$FILE" ]]; then
|
||||||
|
NON_COMPLIANT_FILES="$NON_COMPLIANT_FILES $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$NON_COMPLIANT_FILES" ]; then
|
||||||
|
echo "files=$NON_COMPLIANT_FILES" >> $GITHUB_OUTPUT
|
||||||
|
echo "Files not executable:"
|
||||||
|
for FILE in $NON_COMPLIANT_FILES; do
|
||||||
|
echo "$FILE"
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Check copyright
|
||||||
|
if: always() && steps.changed-files.outputs.files != ''
|
||||||
|
id: check-copyright
|
||||||
|
run: |
|
||||||
|
NON_COMPLIANT_FILES=""
|
||||||
|
for FILE in ${{ steps.changed-files.outputs.files }}; do
|
||||||
|
if ! sed -n '3p' "$FILE" | grep -qE "^# Copyright \(c\) [0-9]{4}(-[0-9]{4})? (tteck \| community-scripts ORG|community-scripts ORG|tteck|asylumexp| asylumexp | asylumexp|asylumexp )$"; then
|
||||||
|
NON_COMPLIANT_FILES="$NON_COMPLIANT_FILES $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$NON_COMPLIANT_FILES" ]; then
|
||||||
|
echo "files=$NON_COMPLIANT_FILES" >> $GITHUB_OUTPUT
|
||||||
|
echo "Copyright header missing or not on line 3 in files:"
|
||||||
|
for FILE in $NON_COMPLIANT_FILES; do
|
||||||
|
echo "$FILE"
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Check author
|
||||||
|
if: always() && steps.changed-files.outputs.files != ''
|
||||||
|
id: check-author
|
||||||
|
run: |
|
||||||
|
NON_COMPLIANT_FILES=""
|
||||||
|
for FILE in ${{ steps.changed-files.outputs.files }}; do
|
||||||
|
if ! sed -n '4p' "$FILE" | grep -qE "^# Author: .+"; then
|
||||||
|
NON_COMPLIANT_FILES="$NON_COMPLIANT_FILES $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$NON_COMPLIANT_FILES" ]; then
|
||||||
|
echo "files=$NON_COMPLIANT_FILES" >> $GITHUB_OUTPUT
|
||||||
|
echo "Author header missing or invalid on line 4 in files:"
|
||||||
|
for FILE in $NON_COMPLIANT_FILES; do
|
||||||
|
echo "$FILE"
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Check license
|
||||||
|
if: always() && steps.changed-files.outputs.files != ''
|
||||||
|
id: check-license
|
||||||
|
run: |
|
||||||
|
NON_COMPLIANT_FILES=""
|
||||||
|
for FILE in ${{ steps.changed-files.outputs.files }}; do
|
||||||
|
if [[ "$(sed -n '5p' "$FILE")" != "# License: MIT | https://github.com/asylumexp/Proxmox/raw/main/LICENSE" ]]; then
|
||||||
|
NON_COMPLIANT_FILES="$NON_COMPLIANT_FILES $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$NON_COMPLIANT_FILES" ]; then
|
||||||
|
echo "files=$NON_COMPLIANT_FILES" >> $GITHUB_OUTPUT
|
||||||
|
echo "License header missing or not on line 5 in files:"
|
||||||
|
for FILE in $NON_COMPLIANT_FILES; do
|
||||||
|
echo "$FILE"
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Check source
|
||||||
|
if: always() && steps.changed-files.outputs.files != ''
|
||||||
|
id: check-source
|
||||||
|
run: |
|
||||||
|
NON_COMPLIANT_FILES=""
|
||||||
|
for FILE in ${{ steps.changed-files.outputs.files }}; do
|
||||||
|
if ! sed -n '6p' "$FILE" | grep -qE "^# Source: .+"; then
|
||||||
|
NON_COMPLIANT_FILES="$NON_COMPLIANT_FILES $FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$NON_COMPLIANT_FILES" ]; then
|
||||||
|
echo "files=$NON_COMPLIANT_FILES" >> $GITHUB_OUTPUT
|
||||||
|
echo "Source header missing or not on line 6 in files:"
|
||||||
|
for FILE in $NON_COMPLIANT_FILES; do
|
||||||
|
echo "$FILE"
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Post results and comment
|
||||||
|
if: always() && steps.changed-files.outputs.files != '' && github.event_name == 'pull_request_target'
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const result = '${{ job.status }}' === 'success' ? 'success' : 'failure';
|
||||||
|
const nonCompliantFiles = {
|
||||||
|
'Invalid build.func source': "${{ steps.build-func.outputs.files }}",
|
||||||
|
'Not executable': "${{ steps.check-executable.outputs.files }}",
|
||||||
|
'Copyright header line missing or invalid': "${{ steps.check-copyright.outputs.files }}",
|
||||||
|
'Author header line missing or invalid': "${{ steps.check-author.outputs.files }}",
|
||||||
|
'License header line missing or invalid': "${{ steps.check-license.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 commentIdentifier = 'validate-scripts';
|
||||||
|
let newCommentBody = `<!-- ${commentIdentifier}-start -->\n### Script validation\n\n`;
|
||||||
|
|
||||||
|
if (result === 'failure') {
|
||||||
|
newCommentBody += ':x: We found issues in the following changed files:\n\n';
|
||||||
|
for (const [check, files] of Object.entries(nonCompliantFiles)) {
|
||||||
|
if (files) {
|
||||||
|
newCommentBody += `**${check}:**\n${files.trim().split(' ').map(file => `- ${file}`).join('\n')}\n\n`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newCommentBody += `:rocket: All changed shell scripts passed validation!\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
newCommentBody += `\n\n<!-- ${commentIdentifier}-end -->`;
|
||||||
|
|
||||||
|
if (issueNumber) {
|
||||||
|
const { data: comments } = await github.rest.issues.listComments({
|
||||||
|
...context.repo,
|
||||||
|
issue_number: issueNumber
|
||||||
|
});
|
||||||
|
|
||||||
|
const existingComment = comments.find(comment => comment.user.login === 'github-actions[bot]');
|
||||||
|
|
||||||
|
if (existingComment) {
|
||||||
|
if (existingComment.body.includes(commentIdentifier)) {
|
||||||
|
const re = new RegExp(String.raw`<!-- ${commentIdentifier}-start -->[\s\S]*?<!-- ${commentIdentifier}-end -->`, "");
|
||||||
|
newCommentBody = existingComment.body.replace(re, newCommentBody);
|
||||||
|
} else {
|
||||||
|
newCommentBody = existingComment.body + '\n\n---\n\n' + newCommentBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
await github.rest.issues.updateComment({
|
||||||
|
...context.repo,
|
||||||
|
comment_id: existingComment.id,
|
||||||
|
body: newCommentBody
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
...context.repo,
|
||||||
|
issue_number: issueNumber,
|
||||||
|
body: newCommentBody
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user