Skip to content

Commit cfbe9e9

Browse files
authored
Merge pull request #136 from johnmhoran/85-add-scheduled-repo-polling
85 add scheduled repo polling
2 parents 05e95e1 + 37fd536 commit cfbe9e9

6 files changed

Lines changed: 417 additions & 19 deletions

File tree

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Update Releases Feed
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# - cron: "15 * * * *" # every hour at :15
7+
- cron: "15 9 * * *" # every day at 09:15 UTC
8+
9+
permissions:
10+
contents: write # needed to commit updates to releases.json
11+
12+
jobs:
13+
update:
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
max-parallel: 1
18+
matrix:
19+
repo:
20+
- aboutcode-org/aboutcode-toolkit
21+
- aboutcode-org/ai-gen-code-search
22+
- aboutcode-org/binary-inspector
23+
- aboutcode-org/commoncode
24+
- aboutcode-org/container-inspector
25+
- aboutcode-org/debian-inspector
26+
- aboutcode-org/dejacode
27+
- aboutcode-org/dependency-inspector
28+
- aboutcode-org/elf-inspector
29+
- aboutcode-org/extractcode
30+
- aboutcode-org/federatedcode
31+
- aboutcode-org/fetchcode
32+
- aboutcode-org/go-inspector
33+
- aboutcode-org/license-expression
34+
- aboutcode-org/matchcode-toolkit
35+
- aboutcode-org/nuget-inspector
36+
- aboutcode-org/plugincode
37+
- aboutcode-org/purldb
38+
- aboutcode-org/purl-validator
39+
- aboutcode-org/purlvalidator-go
40+
- aboutcode-org/pygmars
41+
- aboutcode-org/python-inspector
42+
- aboutcode-org/rust-inspector
43+
- aboutcode-org/saneyaml
44+
- aboutcode-org/scancode.io
45+
- aboutcode-org/scancode-plugins
46+
- aboutcode-org/scancode-toolkit
47+
- aboutcode-org/scancode-workbench
48+
- aboutcode-org/source-inspector
49+
- aboutcode-org/typecode
50+
- aboutcode-org/univers
51+
- aboutcode-org/vulnerablecode
52+
- aboutcode-org/www.aboutcode.org
53+
# Add more repos here
54+
55+
env:
56+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
GITHUB_TOKEN: ${{ secrets.GH_REPO_POLLING }}
58+
59+
steps:
60+
61+
# 1 Checkout the target repo (Repo B)
62+
- name: Checkout repository
63+
uses: actions/checkout@v4
64+
with:
65+
ref: main
66+
fetch-depth: 0
67+
token: ${{ secrets.GH_REPO_POLLING }}
68+
69+
# 2 Debug: show which repo is being processed
70+
- name: Debug - current repo
71+
run: echo "Processing ${{ matrix.repo }}"
72+
73+
# 3 Fetch the latest release from the current source repo
74+
- name: Fetch latest release
75+
run: |
76+
REPO=${{ matrix.repo }}
77+
curl -s -H "Accept: application/vnd.github+json" \
78+
https://api.github.com/repos/$REPO/releases/latest \
79+
-o release.json || echo '{}' > release.json
80+
81+
# 4 Update releases.json in website/static cl
82+
- name: Update releases.json
83+
env:
84+
REPO: ${{ matrix.repo }}
85+
run: |
86+
TMP=$(mktemp)
87+
FILTER=$(mktemp --suffix=.jq)
88+
mkdir -p website/static
89+
if [ ! -f website/static/releases.json ]; then
90+
echo "[]" > website/static/releases.json
91+
fi
92+
printf '%s\n' \
93+
'$existing[0] +' \
94+
'[ $release[0] | {' \
95+
' repo: (if .name==null then "" else .name end),' \
96+
' repo_slug: env.REPO,' \
97+
' repo_url: ("https://github.com/" + env.REPO),' \
98+
' tag: (if .tag_name==null then "" else .tag_name end),' \
99+
' tag_url: (if .html_url==null then "" else .html_url end),' \
100+
' published_at: (if .published_at==null then "" else .published_at end),' \
101+
' releases_page_url: ("https://github.com/" + env.REPO + "/releases"),' \
102+
' compare_url: ("https://github.com/" + env.REPO + "/compare/" + (if .tag_name==null then "" else .tag_name end) + "...main"),' \
103+
' commits_since: 0,' \
104+
' prerelease: .prerelease,' \
105+
' author: (if .author==null then "" else .author.login end)' \
106+
'}' \
107+
'] | sort_by(.published_at) | reverse | unique_by(.repo_url) | sort_by(.published_at) | reverse' \
108+
> "$FILTER"
109+
jq -n \
110+
--slurpfile existing website/static/releases.json \
111+
--slurpfile release release.json \
112+
-f "$FILTER" > "$TMP"
113+
mv "$TMP" website/static/releases.json
114+
rm -f release.json "$FILTER"
115+
shell: bash
116+
117+
# 5 Commit & push changes if releases.json changed
118+
- name: Commit and push if changed
119+
run: |
120+
git config user.name "github-actions"
121+
git config user.email "github-actions@github.com"
122+
git add website/static/releases.json
123+
if ! git diff --cached --quiet; then
124+
git commit -m "Update releases for ${{ matrix.repo }}"
125+
git pull --rebase origin main
126+
git push
127+
else
128+
echo "No changes detected"
129+
fi
130+
shell: bash

website/docs/about/about-releases.md

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Releases
3+
---
4+
5+
import ReleasesTable from '@site/src/components/ReleasesTable';
6+
7+
# Latest Releases
8+
9+
Find information here about the latest releases for ScanCode, VulnerableCode,
10+
and other AboutCode projects.
11+
12+
<ReleasesTable />

website/docusaurus.config.js

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@
66

77
import { themes as prismThemes } from 'prism-react-renderer';
88

9+
// Deployment target: local | gh | dreamhost
10+
/** @type {'local' | 'gh' | 'dreamhost'} */
11+
let deployTarget = 'local';
12+
13+
if (process.env.DEPLOY_TARGET === 'gh') {
14+
deployTarget = 'gh';
15+
} else if (process.env.DEPLOY_TARGET === 'dreamhost') {
16+
deployTarget = 'dreamhost';
17+
}
18+
19+
const siteConfig = {
20+
local: {
21+
url: 'http://localhost',
22+
baseUrl: '/',
23+
},
24+
gh: {
25+
url: 'https://aboutcode-org.github.io',
26+
baseUrl: '/www.aboutcode.org/',
27+
},
28+
dreamhost: {
29+
url: 'https://www.aboutcode.org',
30+
baseUrl: '/',
31+
},
32+
};
33+
934
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
1035

1136
/** @type {import('@docusaurus/types').Config} */
@@ -32,13 +57,13 @@ const config = {
3257
// // For GitHub pages deployment, it is often '/<projectName>/'
3358
// baseUrl: '/',
3459

35-
// // GitHub pages deployment config.
36-
// // If you aren't using GitHub pages, you don't need these.
37-
// organizationName: 'facebook', // Usually your GitHub org/user name.
38-
// projectName: 'docusaurus', // Usually your repo name.
60+
// url: 'https://aboutcode-org.github.io',
61+
// baseUrl: '/www.aboutcode.org/',
62+
// trailingSlash: false,
3963

40-
url: 'https://aboutcode-org.github.io',
41-
baseUrl: '/www.aboutcode.org/',
64+
// 2026-02-19 Thursday 18:06:22. Adapt the www.packageurl.org approach for the GH Pages vs. DreamHost baseUrl adjustment.
65+
url: siteConfig[deployTarget].url,
66+
baseUrl: siteConfig[deployTarget].baseUrl,
4267
trailingSlash: false,
4368

4469
// For GitHub pages deployment:
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import React, { useEffect, useState } from 'react';
2+
import useBaseUrl from '@docusaurus/useBaseUrl';
3+
import styles from './styles.module.css';
4+
5+
export default function ReleasesTable() {
6+
const [data, setData] = useState([]);
7+
const releasesUrl = useBaseUrl('/releases.json');
8+
9+
useEffect(() => {
10+
fetch(releasesUrl)
11+
.then(res => res.json())
12+
.then(setData)
13+
.catch(() => setData([]));
14+
}, [releasesUrl]);
15+
16+
const repos = data.sort(
17+
(a, b) => new Date(b.published_at) - new Date(a.published_at)
18+
);
19+
20+
if (repos.length === 0) return <p>Loading releases...</p>;
21+
22+
return (
23+
<div className={styles.container}>
24+
<table className={styles.table}>
25+
<thead>
26+
<tr>
27+
<th>Repo</th>
28+
<th>Tag</th>
29+
<th>Published</th>
30+
<th>Releases Page</th>
31+
</tr>
32+
</thead>
33+
<tbody>
34+
{repos.map((info, idx) => (
35+
<tr key={idx}>
36+
<td>
37+
<a href={info.repo_url} target='_blank' rel='noreferrer'>
38+
{info.repo_url.replace("https://github.com/", "")}
39+
</a>
40+
</td>
41+
<td>{info.tag}</td>
42+
{/* <td>{new Date(info.published_at).toLocaleDateString()}</td> */}
43+
{/* <td>{new Date(info.published_at).toISOString().replace('T', ' ').replace('.000Z', ' UTC')}</td> */}
44+
<td>{info.published_at ? new Date(info.published_at).toISOString().replace('T', ' ').replace('.000Z', ' UTC') : 'N/A'}</td>
45+
<td>
46+
<a href={info.releases_page_url} target='_blank' rel='noreferrer'>
47+
Releases
48+
</a>
49+
</td>
50+
</tr>
51+
))}
52+
</tbody>
53+
</table>
54+
</div>
55+
);
56+
}

0 commit comments

Comments
 (0)