Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

πŸ‘· Small fixes to tag workflow

Alicia Sykesc921872ed4f2
diff --git a/.github/workflows/bump-and-tag.yml b/.github/workflows/bump-and-tag.yml
index cc05dd88..4378d6aa 100644
--- a/.github/workflows/bump-and-tag.yml
+++ b/.github/workflows/bump-and-tag.yml
@@ -103,14 +103,14 @@ jobs:
script: |
const body = context.payload.pull_request.body || '';
const prNumber = String(context.payload.pull_request.number);
- const matches = body.match(/#(\d+)/g);
+ const matches = body.match(/#(\d+)(?![a-fA-F0-9])/g);
if (!matches) {
core.info('No issue references found in PR body');
core.setOutput('numbers', '');
return;
}
const unique = [...new Set(matches.map(m => m.replace('#', '')))]
- .filter(n => n !== prNumber);
+ .filter(n => n !== prNumber && parseInt(n, 10) > 0);
if (unique.length === 0) {
core.info('No issue references after filtering');
core.setOutput('numbers', '');
@@ -133,6 +133,7 @@ jobs:
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
+ PR_AUTHOR: ${{ github.event.pull_request.user.login }}
MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }}
ISSUES: ${{ steps.issues.outputs.numbers }}
run: |
@@ -143,15 +144,15 @@ jobs:
exit 0
fi
- printf 'Published Dashy v%s πŸš€\n\nPR #%s: %s\nMerge commit: %s\n' \
- "$VERSION" \
- "$PR_NUMBER" \
- "$PR_TITLE" \
- "$MERGE_SHA" > tag-message.txt
-
- if [ -n "$ISSUES" ]; then
- printf 'Resolves: %s\n' "$(echo "$ISSUES" | sed 's/,/, #/g; s/^/#/')" >> tag-message.txt
- fi
+ {
+ printf 'Dashy v%s πŸš€\n\n' "$VERSION"
+ printf 'PR: #%s - %s\n' "$PR_NUMBER" "$PR_TITLE"
+ if [ -n "$ISSUES" ]; then
+ printf 'Resolves: %s\n' "$(echo "$ISSUES" | sed 's/,/, #/g; s/^/#/')"
+ fi
+ printf 'Author: @%s\n' "$PR_AUTHOR"
+ printf 'Merge commit: %s\n' "$MERGE_SHA"
+ } > tag-message.txt
git tag -a "$VERSION" -F tag-message.txt
git push origin "$VERSION"
@@ -188,35 +189,46 @@ jobs:
}
const prNumber = context.payload.pull_request.number;
+ const prAuthor = context.payload.pull_request.user?.login;
+ const creditAuthor = prAuthor && prAuthor.toLowerCase() !== 'lissy93';
const marker = `released-${version}`;
for (const num of issues) {
const issue_number = parseInt(num, 10);
try {
- const comments = await github.rest.issues.listComments({
- owner, repo, issue_number, per_page: 100,
- });
+ const [{ data: issue }, comments] = await Promise.all([
+ github.rest.issues.get({ owner, repo, issue_number }),
+ github.rest.issues.listComments({
+ owner, repo, issue_number, per_page: 100,
+ }),
+ ]);
const alreadyCommented = comments.data.some(
c => c.body?.includes(marker)
);
- await github.rest.issues.addLabels({
- owner, repo, issue_number, labels: [labelName],
- });
if (!alreadyCommented) {
- const body = [
- `An implementation for this ticket was`,
- `merged in #${prNumber} and released in`,
- `version ${version}. To receive this fix,`,
- `ensure you've updated your Dashy instance`,
- `to the ${version} tag or later πŸ˜‡`,
- `<!-- ${marker} -->`,
- ].join(' ');
+ const author = issue.user?.login;
+ const greeting = author ? `Hey @${author},` : 'Hey,';
+ const sixMonthsAgo = new Date();
+ sixMonthsAgo.setMonth(sixMonthsAgo.getMonth() - 6);
+ const isOld = new Date(issue.created_at) < sixMonthsAgo;
+ const byLine = creditAuthor ? ` by @${prAuthor}` : '';
+ const parts = [
+ greeting,
+ `this has now been implemented${byLine} in #${prNumber},`,
+ `and will be released shortly in ${version} πŸ˜‡`,
+ ];
+ if (isOld) parts.push(`\n\nWe're sorry this one took so long πŸ˜”`);
+ parts.push(`<!-- ${marker} -->`);
+ const body = parts.join(' ');
await github.rest.issues.createComment({
owner, repo, issue_number, body,
});
- core.info(`Labeled and commented on #${num}`);
- } else {
- core.info(`Already commented on #${num}, skipped`);
}
+ await github.rest.issues.addLabels({
+ owner, repo, issue_number, labels: [labelName, 'βœ… Fixed'],
+ });
+ core.info(alreadyCommented
+ ? `Already commented on #${num}, labels applied`
+ : `Commented and labeled #${num}`);
} catch (e) {
core.warning(`Failed to process #${num}: ${e.message}`);
}
diff --git a/.github/workflows/close-stale-issues.yml b/.github/workflows/close-stale-issues.yml
index 236e03e5..98ddd551 100644
--- a/.github/workflows/close-stale-issues.yml
+++ b/.github/workflows/close-stale-issues.yml
@@ -1,5 +1,6 @@
# Closes issues that are inactive, likely non-issues, or awaiting a response that never came.
-# Runs daily. Skips issues with active discussion (>5 comments), milestones, or assignees.
+# Runs daily. Skips issues with active discussion (3+ non-bot comments), reopened issues,
+# milestones, or assignees.
name: 🎯 Close Stale Issues
on:
@@ -16,22 +17,50 @@ jobs:
runs-on: ubuntu-latest
steps:
- - name: Exempt actively discussed issues πŸ’¬
+ - name: Exempt actively discussed or reopened issues πŸ’¬
uses: actions/github-script@v8
with:
github-token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
+ const KEEP_OPEN = 'πŸ“Œ Keep Open';
+ const BOT = 'liss-bot';
+ const MIN = 3;
+
+ const exempt = (number, reason) => github.rest.issues
+ .addLabels({ owner, repo, issue_number: number, labels: [KEEP_OPEN] })
+ .then(() => core.info(`Exempted #${number} (${reason})`));
+
+ const hasEnoughHumanComments = async (issue) => {
+ if (issue.comments < MIN) return false;
+ const comments = await github.paginate(github.rest.issues.listComments, {
+ owner, repo, issue_number: issue.number, per_page: 100,
+ });
+ return comments.filter(c => c.user?.login !== BOT).length >= MIN;
+ };
+
+ const wasReopened = async (number) => {
+ const { data } = await github.rest.issues.listEvents({
+ owner, repo, issue_number: number, per_page: 100,
+ });
+ return data.some(e => e.event === 'reopened');
+ };
+
const issues = await github.paginate(github.rest.issues.listForRepo, {
owner, repo, state: 'open', per_page: 100,
});
+
for (const issue of issues) {
if (issue.pull_request) continue;
- if (issue.comments > 5 && !issue.labels.some(l => l.name === 'πŸ“Œ Keep Open')) {
- await github.rest.issues.addLabels({
- owner, repo, issue_number: issue.number, labels: ['πŸ“Œ Keep Open'],
- });
- core.info(`Exempted issue #${issue.number} (${issue.comments} comments)`);
+ if (issue.labels.some(l => l.name === KEEP_OPEN)) continue;
+ try {
+ if (await hasEnoughHumanComments(issue)) {
+ await exempt(issue.number, '3+ non-bot comments');
+ } else if (await wasReopened(issue.number)) {
+ await exempt(issue.number, 'previously reopened');
+ }
+ } catch (e) {
+ core.warning(`Failed to process #${issue.number}: ${e.message}`);
}
}