From 9d8e5e4705da603f7b758797dd555d98fc4e00c4 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 18 Mar 2025 20:49:01 +0100 Subject: [PATCH] remove old backups (#3247) --- .../backup/check_and_update_json_date.yml | 60 ----- .github/workflows/backup/shellcheck.yml | 60 ----- .../workflows/backup/update_json_date.yml.bak | 88 ------- .../backup/validate-formatting.yaml.bak | 133 ---------- .../workflows/backup/validate-scripts.yml.bak | 234 ------------------ 5 files changed, 575 deletions(-) delete mode 100644 .github/workflows/backup/check_and_update_json_date.yml delete mode 100644 .github/workflows/backup/shellcheck.yml delete mode 100644 .github/workflows/backup/update_json_date.yml.bak delete mode 100644 .github/workflows/backup/validate-formatting.yaml.bak delete mode 100644 .github/workflows/backup/validate-scripts.yml.bak diff --git a/.github/workflows/backup/check_and_update_json_date.yml b/.github/workflows/backup/check_and_update_json_date.yml deleted file mode 100644 index cde3cbbad..000000000 --- a/.github/workflows/backup/check_and_update_json_date.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Update date_created in JSON files - -on: - # Dieser Trigger wird für das Öffnen von PRs sowie für das Aktualisieren von offenen PRs verwendet - pull_request: - types: [opened, synchronize] - schedule: - # Dieser Trigger wird 4x am Tag ausgelöst, um sicherzustellen, dass das Datum aktualisiert wird - - cron: "0 0,6,12,18 * * *" # Führt alle 6 Stunden aus - workflow_dispatch: # Manuelle Ausführung des Workflows möglich - -jobs: - update-date: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install yq - run: | - sudo apt-get update - sudo apt-get install -y yq - - - name: Set the current date - id: set_date - run: echo "TODAY=$(date -u +%Y-%m-%d)" >> $GITHUB_ENV - - - name: Check for changes in PR - run: | - # Hole den PR-Branch - PR_BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge" - git fetch origin $PR_BRANCH - - # Liste alle JSON-Dateien im PR auf, die geändert wurden - CHANGED_JSON_FILES=$(git diff --name-only origin/main...$PR_BRANCH | grep '.json') - - if [ -z "$CHANGED_JSON_FILES" ]; then - echo "No JSON files changed in this PR." - exit 0 - fi - - # Gehe alle geänderten JSON-Dateien durch und aktualisiere das Datum - for file in $CHANGED_JSON_FILES; do - echo "Updating date_created in $file" - # Setze das aktuelle Datum - yq eval ".date_created = \"${{ env.TODAY }}\"" -i "$file" - git add "$file" - done - - - name: Commit and push changes - run: | - # Prüfe, ob es Änderungen gibt und committe sie - git config user.name "json-updater-bot" - git config user.email "github-actions[bot]@users.noreply.github.com" - - git commit -m "Update date_created to ${{ env.TODAY }}" || echo "No changes to commit" - - # Push zurück in den PR-Branch - git push origin $PR_BRANCH diff --git a/.github/workflows/backup/shellcheck.yml b/.github/workflows/backup/shellcheck.yml deleted file mode 100644 index 4385fc8e9..000000000 --- a/.github/workflows/backup/shellcheck.yml +++ /dev/null @@ -1,60 +0,0 @@ -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: changed-files - uses: tj-actions/changed-files@v45 - with: - files: | - **.sh - - - name: Download ShellCheck - shell: bash - env: - INPUT_VERSION: "v0.10.0" - run: | - set -euo pipefail - if [[ "${{ runner.os }}" == "macOS" ]]; then - osvariant="darwin" - else - osvariant="linux" - fi - - baseurl="https://github.com/koalaman/shellcheck/releases/download" - curl -Lso "${{ github.workspace }}/sc.tar.xz" \ - "${baseurl}/${INPUT_VERSION}/shellcheck-${INPUT_VERSION}.${osvariant}.x86_64.tar.xz" - - tar -xf "${{ github.workspace }}/sc.tar.xz" -C "${{ github.workspace }}" - mv "${{ github.workspace }}/shellcheck-${INPUT_VERSION}/shellcheck" \ - "${{ github.workspace }}/shellcheck" - - - name: Verify ShellCheck binary - run: | - ls -l "${{ github.workspace }}/shellcheck" - - - name: Display ShellCheck version - run: | - "${{ github.workspace }}/shellcheck" --version - - - name: Run ShellCheck - if: steps.changed-files.outputs.any_changed == 'true' - env: - ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} - run: | - echo "${ALL_CHANGED_FILES}" | xargs "${{ github.workspace }}/shellcheck" diff --git a/.github/workflows/backup/update_json_date.yml.bak b/.github/workflows/backup/update_json_date.yml.bak deleted file mode 100644 index cb9bc8559..000000000 --- a/.github/workflows/backup/update_json_date.yml.bak +++ /dev/null @@ -1,88 +0,0 @@ -name: Auto Update JSON-Date - -on: - push: - branches: - - main - workflow_dispatch: - -jobs: - update-json-dates: - runs-on: ubuntu-latest - - permissions: - contents: write - pull-requests: write - - steps: - - name: Generate a token - id: generate-token - uses: actions/create-github-app-token@v1 - with: - app-id: ${{ vars.APP_ID }} - private-key: ${{ secrets.APP_PRIVATE_KEY }} - - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Full history for proper detection - - - name: Set up Git - run: | - git config --global user.name "GitHub Actions" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - - - name: Find JSON files with incorrect date_created - id: find_wrong_json - run: | - TODAY=$(date -u +"%Y-%m-%d") - > incorrect_json_files.txt - - for FILE in json/*.json; do - if [[ -f "$FILE" ]]; then - DATE_IN_JSON=$(jq -r '.date_created' "$FILE" 2>/dev/null || echo "") - - if [[ "$DATE_IN_JSON" != "$TODAY" ]]; then - echo "$FILE" >> incorrect_json_files.txt - fi - fi - done - - if [[ -s incorrect_json_files.txt ]]; then - echo "CHANGED=true" >> $GITHUB_ENV - else - echo "CHANGED=false" >> $GITHUB_ENV - fi - - - name: Run update script - if: env.CHANGED == 'true' - run: | - chmod +x .github/workflows/scripts/update-json.sh - while read -r FILE; do - .github/workflows/scripts/update-json.sh "$FILE" - done < incorrect_json_files.txt - - - name: Commit and create PR if changes exist - if: env.CHANGED == 'true' - run: | - git add json/*.json - git commit -m "Auto-update date_created in incorrect JSON files" - git checkout -b pr-fix-json-dates - git push origin pr-fix-json-dates --force - gh pr create --title "[core] Fix incorrect JSON date_created fields" \ - --body "This PR is auto-generated to fix incorrect `date_created` fields in JSON files." \ - --head pr-fix-json-dates \ - --base main \ - --label "automated pr" - env: - GH_TOKEN: ${{ steps.generate-token.outputs.token }} - - - name: Approve pull request - if: env.CHANGED == 'true' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - PR_NUMBER=$(gh pr list --head "pr-fix-json-dates" --json number --jq '.[].number') - if [ -n "$PR_NUMBER" ]; then - gh pr review $PR_NUMBER --approve - fi diff --git a/.github/workflows/backup/validate-formatting.yaml.bak b/.github/workflows/backup/validate-formatting.yaml.bak deleted file mode 100644 index 8eadd0acf..000000000 --- a/.github/workflows/backup/validate-formatting.yaml.bak +++ /dev/null @@ -1,133 +0,0 @@ -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 = `\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`; - - 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`[\s\S]*?`, - "", - ); - 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, - }); - } - } diff --git a/.github/workflows/backup/validate-scripts.yml.bak b/.github/workflows/backup/validate-scripts.yml.bak deleted file mode 100644 index 84b697063..000000000 --- a/.github/workflows/backup/validate-scripts.yml.bak +++ /dev/null @@ -1,234 +0,0 @@ -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: Debug event payload - run: | - echo "Event name: ${{ github.event_name }}" - echo "Payload: $(cat $GITHUB_EVENT_PATH)" - - - 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 - 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: 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/community-scripts/ProxmoxVE/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)$"; 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/community-scripts/ProxmoxVE/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 = `\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(' ').forEach(file => { - newCommentBody += `- ${file}: ${check}\n`; - }); - newCommentBody += `\n`; - } - } - } else { - newCommentBody += `:rocket: All changed shell scripts passed validation!\n`; - } - - newCommentBody += `\n\n`; - - if (issueNumber) { - const { data: comments } = await github.rest.issues.listComments({ - ...context.repo, - issue_number: issueNumber - }); - - const existingComment = comments.find(comment => - comment.body.includes(``) && - comment.user.login === 'github-actions[bot]' - ); - - if (existingComment) { - const re = new RegExp(String.raw`[\\s\\S]*?`, "m"); - newCommentBody = existingComment.body.replace(re, 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 - }); - } - }