Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions .github/workflows/dependabot-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Dependabot Changelog Updater

on:
pull_request:
types: [opened, synchronize]

permissions:
contents: write

jobs:
update-changelog:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: '20'

- name: Update Changelog
run: |
cat << 'JS' > update-changelog.js
const fs = require('fs');
const prTitle = "Update application software dependencies";

if (!prTitle) {
console.error("No PR title found.");
process.exit(1);
}

// Update CHANGELOG.md
let mdContent = fs.readFileSync('CHANGELOG.md', 'utf8');
if (!mdContent.includes(prTitle)) {
const marker = '## [';
const insertIndex = mdContent.indexOf(marker);
if (insertIndex !== -1) {
if (mdContent.substring(insertIndex, insertIndex + 20).includes('[NEXT_VERSION]')) {
const nextLineIndex = mdContent.indexOf('\n', insertIndex);
mdContent = mdContent.slice(0, nextLineIndex + 1) + `- ${prTitle}\n` + mdContent.slice(nextLineIndex + 1);
} else {
const newEntry = `## [[NEXT_VERSION]] - [NEXT_DATE]\n- ${prTitle}\n\n`;
mdContent = mdContent.slice(0, insertIndex) + newEntry + mdContent.slice(insertIndex);
}
fs.writeFileSync('CHANGELOG.md', mdContent);
}
}

// Update assets/changelog.json
let jsonContent = JSON.parse(fs.readFileSync('assets/changelog.json', 'utf8'));
let found = false;
if (jsonContent[0].version === '[NEXT_VERSION]') {
if (jsonContent[0].changes.includes(prTitle)) {
found = true;
} else {
jsonContent[0].changes.push(prTitle);
found = true;
}
}
if (!found) {
jsonContent.unshift({
version: '[NEXT_VERSION]',
date: '[NEXT_DATE]',
changes: [prTitle]
});
}
fs.writeFileSync('assets/changelog.json', JSON.stringify(jsonContent, null, 2) + '\n');
JS

node update-changelog.js
- name: Commit and Push
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add CHANGELOG.md assets/changelog.json
if git diff --cached --quiet; then
echo "No changelog updates needed."
else
git commit -m "chore: update changelog for dependabot PR [skip ci]"
# Use the explicit repository URL with the token to push
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git push origin HEAD:${{ github.head_ref }}
fi
41 changes: 41 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Lint and Auto-fix

on:
pull_request:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run linter and auto-fix
run: |
npm run lint:js -- --fix
npm run lint:md -- --fix

- name: Commit fixes
if: always()
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git diff --quiet || (git add -u && git commit -m "chore: auto-fix linting errors" && git push origin HEAD:${{ github.head_ref }})
27 changes: 27 additions & 0 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: PR Test Coverage

on:
pull_request:
branches:
- main

permissions:
pull-requests: write
checks: write
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: '20'
cache: 'npm'
- run: npm ci
- run: npm test -- --coverage
- uses: artiomtr/jest-coverage-report-action@262a7bb0b20c4d1d6b6b026af0f008f78da72788 # v2.3.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
threshold: 0
127 changes: 0 additions & 127 deletions .github/workflows/pr-version.yml

This file was deleted.

Loading
Loading