Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a GitHub Action to close issues with outdated versions #3652

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
53 changes: 53 additions & 0 deletions .github/workflows/bug-report-version.yml
Original file line number Diff line number Diff line change
@@ -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'
});
}
}