This commit is contained in:
Ryan Luu 2025-03-30 23:57:44 +01:00 committed by GitHub
commit 353198df03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,53 @@
name: Check Bug Report Version
on:
issues:
types: [opened]
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get latest version
id: read-version
run: |
version=$(grep -oPm1 "(?<=<Version>)[^<]+" Bloxstrap/Bloxstrap.csproj)
echo "version=$version" >> $GITHUB_OUTPUT
- name: Check issue for Bloxstrap version
uses: actions/github-script@v7
id: check-issue
with:
script: |
const issueBody = context.payload.issue.body;
const versionHeader = issueBody.match(/### Bloxstrap Version/);
const versionMatch = issueBody.match(/v?\d+[\.,]\d+[\.,]\d+/);
const latestVersion = '${{ steps.read-version.outputs.version }}';
if (versionHeader && !versionMatch) {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Please specify the Bloxstrap version you are using. Use the format `vX.Y.Z`.'
});
} else if (versionMatch) {
const issueVersion = versionMatch[0];
if (issueVersion !== latestVersion) {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `You are using an outdated version of Bloxstrap (${issueVersion}). Please update to the [latest version of Bloxstrap](https://github.com/pizzaboxer/bloxstrap/releases/latest). If you are still experiencing the bug, please reopen this issue.`
});
return github.rest.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed',
state_reason: 'not_planned'
});
}
}