-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (54 loc) · 2.11 KB
/
cron.yml
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
name: Open Issue when monitored repos release a new version
on:
schedule:
- cron: 45 12 1 * *
jobs:
create_issue:
name: Open Issue when monitored repos release a new version
runs-on: ubuntu-latest
container:
image: ubuntu:latest
permissions:
issues: write
steps:
- name: Open Issue when monitored repos release a new version
shell: bash
run: |
apt update -y
apt install -y curl jq wget
url=$(curl -s https://api.github.com/repos/cli/cli/releases/latest | jq -r '.assets[].browser_download_url|select(contains("linux") and contains("amd64") and contains(".deb"))')
wget $url
apt install -y ./gh_*_linux_amd64.deb
rm gh_*_linux_amd64.deb
if ! gh --version; then
echo "GitHub CLI was not installed"
exit 1
fi
for repo in $MONITORED_REPOS; do
project=$(echo $repo | cut -d '/' -f 2)
previous_issue_date=$(gh issue list \
--repo $GH_REPO \
--json createdAt \
-s all \
-S "[Chore]: Upgrade $project to" \
-L 1 \
--jq '.[0].createdAt' \
| tr -d '"')
new_release=$(gh release list -R $repo \
--exclude-drafts \
--exclude-pre-releases \
--json publishedAt,tagName \
--jq '.[0]')
new_release_tag=$(echo $new_release | jq '.tagName' | tr -d '"')
new_release_date=$(echo $new_release | jq '.publishedAt' | tr -d '"')
if [[ "$previous_issue_date" < "$new_release_date" ]]; then
gh issue create \
--repo $GH_REPO \
--title "[Chore]: Upgrade $project to $new_release_tag" \
--body "$(gh release view $new_release_tag --repo $repo --json body --jq '.body')"
fi
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
MONITORED_REPOS: 'netbox-community/netbox netbox-community/netbox-docker ytti/oxidized librenms/librenms'