-
Notifications
You must be signed in to change notification settings - Fork 258
99 lines (77 loc) · 3.94 KB
/
auto_close_missing_support.yml
File metadata and controls
99 lines (77 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# This file is part of PixelFlasher https://github.com/badabing2005/PixelFlasher
#
# Copyright (C) 2025 Badabing2005
# SPDX-FileCopyrightText: 2025 Badabing2005
# SPDX-License-Identifier: AGPL-3.0-or-later
name: Auto Close Issues Without Support Files
on:
issues:
types: [opened, edited]
jobs:
check_support_file:
runs-on: ubuntu-latest
if: contains(github.event.issue.body, 'Support File Status') && contains(github.event.issue.body, 'Support File Attachment') && !contains(github.event.issue.body, 'I cannot generate a support file')
steps:
- name: Extract and verify support file attachment
id: verify_support
run: |
body=$(jq -r '.issue.body // ""' "$GITHUB_EVENT_PATH")
has_valid_file=false
urls=$(echo "$body" | grep -o 'https://github\.com/[^ )]*' | grep 'files/[0-9]' | sort -u)
if [ -z "$urls" ]; then
echo "No attachment URLs found in body"
echo "has_valid_file=false" >> "$GITHUB_OUTPUT"
exit 0
fi
tmpdir=$(mktemp -d)
echo "Found $(echo "$urls" | wc -l) attachment URL(s), checking validity..."
for url in $urls; do
echo "Checking: $url"
# Download with redirect follow (-L), silent (-s), fail on error (--fail)
status=$(curl -L -s -o "${tmpdir}/downloaded.zip" -w "%{http_code}" --fail "$url" 2>/dev/null || echo "000")
if [ "$status" = "200" ] && [ -s "${tmpdir}/downloaded.zip" ]; then
echo " Download succeeded (HTTP $status, $(wc -c < "${tmpdir}/downloaded.zip") bytes)"
# Verify it's a valid zip file
if unzip -tq "${tmpdir}/downloaded.zip" 2>/dev/null; then
echo " Valid zip file confirmed"
# Verify contents contain only pf.dat and support.pf
zip_contents=$(unzip -Z1 "${tmpdir}/downloaded.zip" 2>/dev/null | sort)
expected=$'pf.dat\nsupport.pf'
if [ "$zip_contents" = "$expected" ]; then
echo " Zip contents verified: only pf.dat and support.pf present"
has_valid_file=true
break
else
echo " Zip contents are invalid. Found: $(echo "$zip_contents" | tr '\n' ' ')"
fi
else
echo " Downloaded file is NOT a valid zip"
fi
else
echo " Download failed (HTTP $status or empty file)"
fi
done
rm -rf "$tmpdir"
echo "has_valid_file=$has_valid_file" >> "$GITHUB_OUTPUT"
- name: Close Issue if no valid support file
if: steps.verify_support.outputs.has_valid_file == 'false'
uses: peter-evans/close-issue@v3
with:
issue-number: ${{ github.event.issue.number }}
comment: |
This issue has been automatically closed because it does not include a valid, attached support file.
## Required Support File Format
An encrypted support file named in the format Support_YYYY-MM-DD_hh-mm-ss.zip is required to process your issue. This file is encrypted to protect your privacy.
## How to Generate a Support File
1. Open PixelFlasher
2. Click the "Support" button or select it from the Help menu
3. Save the generated file (it will be automatically named correctly and encrypted for your privacy)
4. Attach this file to your issue — **you must actually drag and drop the file, not just paste a URL or filename**
## Next Steps
You may reopen this issue by:
1. Clicking the "Edit" button on your original issue
2. Attaching the properly named support file (the .zip file itself, not a link to it)
3. Commenting that you've added the required file
Thank you for your understanding.
labels: "invalid"
close-reason: "not_planned"