-
-
Notifications
You must be signed in to change notification settings - Fork 14
130 lines (119 loc) · 4.63 KB
/
update-releases.yml
File metadata and controls
130 lines (119 loc) · 4.63 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Update Releases Feed
on:
workflow_dispatch:
schedule:
# - cron: "15 * * * *" # every hour at :15
- cron: "15 9 * * *" # every day at 09:15 UTC
permissions:
contents: write # needed to commit updates to releases.json
jobs:
update:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
repo:
- aboutcode-org/aboutcode-toolkit
- aboutcode-org/ai-gen-code-search
- aboutcode-org/binary-inspector
- aboutcode-org/commoncode
- aboutcode-org/container-inspector
- aboutcode-org/debian-inspector
- aboutcode-org/dejacode
- aboutcode-org/dependency-inspector
- aboutcode-org/elf-inspector
- aboutcode-org/extractcode
- aboutcode-org/federatedcode
- aboutcode-org/fetchcode
- aboutcode-org/go-inspector
- aboutcode-org/license-expression
- aboutcode-org/matchcode-toolkit
- aboutcode-org/nuget-inspector
- aboutcode-org/plugincode
- aboutcode-org/purldb
- aboutcode-org/purl-validator
- aboutcode-org/purlvalidator-go
- aboutcode-org/pygmars
- aboutcode-org/python-inspector
- aboutcode-org/rust-inspector
- aboutcode-org/saneyaml
- aboutcode-org/scancode.io
- aboutcode-org/scancode-plugins
- aboutcode-org/scancode-toolkit
- aboutcode-org/scancode-workbench
- aboutcode-org/source-inspector
- aboutcode-org/typecode
- aboutcode-org/univers
- aboutcode-org/vulnerablecode
- aboutcode-org/www.aboutcode.org
# Add more repos here
env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_REPO_POLLING }}
steps:
# 1 Checkout the target repo (Repo B)
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
token: ${{ secrets.GH_REPO_POLLING }}
# 2 Debug: show which repo is being processed
- name: Debug - current repo
run: echo "Processing ${{ matrix.repo }}"
# 3 Fetch the latest release from the current source repo
- name: Fetch latest release
run: |
REPO=${{ matrix.repo }}
curl -s -H "Accept: application/vnd.github+json" \
https://api.github.com/repos/$REPO/releases/latest \
-o release.json || echo '{}' > release.json
# 4 Update releases.json in website/static cl
- name: Update releases.json
env:
REPO: ${{ matrix.repo }}
run: |
TMP=$(mktemp)
FILTER=$(mktemp --suffix=.jq)
mkdir -p website/static
if [ ! -f website/static/releases.json ]; then
echo "[]" > website/static/releases.json
fi
printf '%s\n' \
'$existing[0] +' \
'[ $release[0] | {' \
' repo: (if .name==null then "" else .name end),' \
' repo_slug: env.REPO,' \
' repo_url: ("https://github.com/" + env.REPO),' \
' tag: (if .tag_name==null then "" else .tag_name end),' \
' tag_url: (if .html_url==null then "" else .html_url end),' \
' published_at: (if .published_at==null then "" else .published_at end),' \
' releases_page_url: ("https://github.com/" + env.REPO + "/releases"),' \
' compare_url: ("https://github.com/" + env.REPO + "/compare/" + (if .tag_name==null then "" else .tag_name end) + "...main"),' \
' commits_since: 0,' \
' prerelease: .prerelease,' \
' author: (if .author==null then "" else .author.login end)' \
'}' \
'] | sort_by(.published_at) | reverse | unique_by(.repo_url) | sort_by(.published_at) | reverse' \
> "$FILTER"
jq -n \
--slurpfile existing website/static/releases.json \
--slurpfile release release.json \
-f "$FILTER" > "$TMP"
mv "$TMP" website/static/releases.json
rm -f release.json "$FILTER"
shell: bash
# 5 Commit & push changes if releases.json changed
- name: Commit and push if changed
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add website/static/releases.json
if ! git diff --cached --quiet; then
git commit -m "Update releases for ${{ matrix.repo }}"
git pull --rebase origin main
git push
else
echo "No changes detected"
fi
shell: bash