This commit is contained in:
CanbiZ 2025-07-21 07:48:43 +02:00
parent 39e68296ee
commit cda8d23a39
7 changed files with 34 additions and 16 deletions

View File

@ -21,6 +21,8 @@ jobs:
with: with:
app-id: ${{ vars.APP_ID }} app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }} private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: community-scripts
repositories: ProxmoxVED
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4

View File

@ -23,6 +23,8 @@ jobs:
with: with:
app-id: ${{ vars.APP_ID }} app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }} private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: community-scripts
repositories: ProxmoxVED
- name: Generate a token for PR approval and merge - name: Generate a token for PR approval and merge
id: generate-token-merge id: generate-token-merge
@ -30,6 +32,8 @@ jobs:
with: with:
app-id: ${{ secrets.APP_ID_APPROVE_AND_MERGE }} app-id: ${{ secrets.APP_ID_APPROVE_AND_MERGE }}
private-key: ${{ secrets.APP_KEY_APPROVE_AND_MERGE }} private-key: ${{ secrets.APP_KEY_APPROVE_AND_MERGE }}
owner: community-scripts
repositories: ProxmoxVED
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4

View File

@ -20,6 +20,8 @@ jobs:
with: with:
app-id: ${{ secrets.APP_ID_APPROVE_AND_MERGE }} app-id: ${{ secrets.APP_ID_APPROVE_AND_MERGE }}
private-key: ${{ secrets.APP_KEY_APPROVE_AND_MERGE }} private-key: ${{ secrets.APP_KEY_APPROVE_AND_MERGE }}
owner: community-scripts
repositories: ProxmoxVED
- name: Extract Issue Title (Lowercase & Underscores) - name: Extract Issue Title (Lowercase & Underscores)
id: extract_title id: extract_title

View File

@ -28,6 +28,8 @@ jobs:
with: with:
app-id: ${{ vars.APP_ID }} app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }} private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: community-scripts
repositories: ProxmoxVED
- name: Crawl from Github API - name: Crawl from Github API
env: env:

View File

@ -28,6 +28,8 @@ jobs:
with: with:
app-id: ${{ vars.APP_ID }} app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }} private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: community-scripts
repositories: ProxmoxVED
- name: Generate a token for PR approval and merge - name: Generate a token for PR approval and merge
id: generate-token-merge id: generate-token-merge
@ -35,6 +37,8 @@ jobs:
with: with:
app-id: ${{ secrets.APP_ID_APPROVE_AND_MERGE }} app-id: ${{ secrets.APP_ID_APPROVE_AND_MERGE }}
private-key: ${{ secrets.APP_KEY_APPROVE_AND_MERGE }} private-key: ${{ secrets.APP_KEY_APPROVE_AND_MERGE }}
owner: community-scripts
repositories: ProxmoxVED
- name: Crawl from newreleases.io - name: Crawl from newreleases.io
env: env:

View File

@ -22,6 +22,8 @@ jobs:
with: with:
app-id: ${{ vars.APP_ID }} app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }} private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: community-scripts
repositories: ProxmoxVED
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -109,7 +111,7 @@ jobs:
); );
if (updateScriptsCategory) { if (updateScriptsCategory) {
const subCategory = updateScriptsCategory.subCategories.find(sub => const subCategory = updateScriptsCategory.subCategories.find(sub =>
sub.labels.some(label => prLabels.includes(label)) sub.labels.some(label => prLabels.includes(label))
); );
@ -121,7 +123,7 @@ jobs:
} }
} }
}); });
console.log(JSON.stringify(categorizedPRs, null, 2)); console.log(JSON.stringify(categorizedPRs, null, 2));
return categorizedPRs; return categorizedPRs;
@ -147,30 +149,30 @@ jobs:
const hasSubcategories = subCategories && subCategories.length > 0; const hasSubcategories = subCategories && subCategories.length > 0;
const hasMainNotes = notes.length > 0; const hasMainNotes = notes.length > 0;
const hasSubNotes = hasSubcategories && subCategories.some(sub => sub.notes && sub.notes.length > 0); const hasSubNotes = hasSubcategories && subCategories.some(sub => sub.notes && sub.notes.length > 0);
if (hasMainNotes || hasSubNotes) { if (hasMainNotes || hasSubNotes) {
newReleaseNotes += `### ${title}\n\n`; newReleaseNotes += `### ${title}\n\n`;
} }
if (hasMainNotes) { if (hasMainNotes) {
newReleaseNotes += ` ${notes.join("\n")}\n\n`; newReleaseNotes += ` ${notes.join("\n")}\n\n`;
} }
if (hasSubcategories) { if (hasSubcategories) {
for (const { title: subTitle, notes: subNotes } of subCategories) { for (const { title: subTitle, notes: subNotes } of subCategories) {
if (subNotes && subNotes.length > 0) { if (subNotes && subNotes.length > 0) {
newReleaseNotes += ` - #### ${subTitle}\n\n`; newReleaseNotes += ` - #### ${subTitle}\n\n`;
newReleaseNotes += ` ${subNotes.join("\n ")}\n\n`; newReleaseNotes += ` ${subNotes.join("\n ")}\n\n`;
} }
} }
} }
} }
const changelogContent = await fs.readFile(changelogPath, 'utf-8'); const changelogContent = await fs.readFile(changelogPath, 'utf-8');
const changelogIncludesTodaysReleaseNotes = changelogContent.includes(`\n## ${today}`); const changelogIncludesTodaysReleaseNotes = changelogContent.includes(`\n## ${today}`);
const regex = changelogIncludesTodaysReleaseNotes const regex = changelogIncludesTodaysReleaseNotes
? new RegExp(`## ${today}.*(?=## ${latestDateInChangelog})`, "gs") ? new RegExp(`## ${today}.*(?=## ${latestDateInChangelog})`, "gs")
: new RegExp(`(?=## ${latestDateInChangelog})`, "gs"); : new RegExp(`(?=## ${latestDateInChangelog})`, "gs");
const newChangelogContent = changelogContent.replace(regex, newReleaseNotes); const newChangelogContent = changelogContent.replace(regex, newReleaseNotes);
@ -223,4 +225,4 @@ jobs:
PR_NUMBER=$(gh pr list --head "${BRANCH_NAME}" --json number --jq '.[].number') PR_NUMBER=$(gh pr list --head "${BRANCH_NAME}" --json number --jq '.[].number')
if [ -n "$PR_NUMBER" ]; then if [ -n "$PR_NUMBER" ]; then
gh pr review $PR_NUMBER --approve gh pr review $PR_NUMBER --approve
fi fi

View File

@ -6,7 +6,7 @@ on:
- main - main
paths: paths:
- 'json/**.json' - 'json/**.json'
workflow_dispatch: workflow_dispatch:
jobs: jobs:
update-app-files: update-app-files:
@ -23,11 +23,13 @@ jobs:
with: with:
app-id: ${{ vars.APP_ID }} app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }} private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: community-scripts
repositories: ProxmoxVED
- name: Generate dynamic branch name - name: Generate dynamic branch name
id: timestamp id: timestamp
run: echo "BRANCH_NAME=pr-update-json-$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV run: echo "BRANCH_NAME=pr-update-json-$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
- name: Set up GH_TOKEN - name: Set up GH_TOKEN
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@ -102,8 +104,8 @@ jobs:
- name: Commit and create PR if changes exist - name: Commit and create PR if changes exist
if: env.changed == 'true' if: env.changed == 'true'
run: | run: |
git commit -m "Update date in json" git commit -m "Update date in json"
git checkout -b ${{ env.BRANCH_NAME }} git checkout -b ${{ env.BRANCH_NAME }}
git push origin ${{ env.BRANCH_NAME }} git push origin ${{ env.BRANCH_NAME }}