Repository navigation
56 lines (47 loc) · 2.28 KB
/
Copy pathcheck-mkbrr-updates.yaml
File metadata and controls
56 lines (47 loc) · 2.28 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
name: Check for New mkbrr Release
on:
schedule:
- cron: "0 12 * * 1" # Runs every Monday at 12:00 UTC
workflow_dispatch:
jobs:
check-release:
runs-on: ubuntu-latest
steps:
- name: Get Latest Release Tag
id: get_release
run: |
LATEST_TAG=$(curl -s https://api.github.com/repos/autobrr/mkbrr/releases/latest | jq -r .tag_name)
echo "Latest mkbrr release: $LATEST_TAG"
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
- name: Check if Issue Already Exists for This Version
id: check_issue
run: |
# Get all issues with the mkbrr label
ISSUES=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues?state=all&labels=mkbrr&per_page=100")
# Check if any issue already mentions this specific release tag
ISSUE_EXISTS=$(echo "$ISSUES" | jq -r --arg tag "$LATEST_TAG" \
'[.[] | select(.body | contains($tag))] | length')
if [[ "$ISSUE_EXISTS" -gt 0 ]]; then
echo "Issue already exists for mkbrr release $LATEST_TAG"
echo "ISSUE_EXISTS=true" >> $GITHUB_ENV
else
echo "No issue exists for mkbrr release $LATEST_TAG"
echo "ISSUE_EXISTS=false" >> $GITHUB_ENV
echo "NEW_RELEASE=true" >> $GITHUB_ENV
fi
- name: Create GitHub Issue Notification
if: env.NEW_RELEASE == 'true' && env.ISSUE_EXISTS == 'false'
run: |
# Create issue body with proper variable expansion
ISSUE_BODY="A new mkbrr release ($LATEST_TAG) has been detected. Consider running the update workflow to incorporate the latest mkbrr binaries into Upload-Assistant."
# Use the variable in the JSON payload
curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-d "{
\"title\": \"New mkbrr Release Available!\",
\"body\": \"$ISSUE_BODY\",
\"labels\": [\"mkbrr\", \"update\"]
}" \
"https://api.github.com/repos/${{ github.repository }}/issues"
echo "Created new issue for mkbrr release $LATEST_TAG"