Skip to content

Commit 67ea096

Browse files
authored
Merge pull request #9 from aboutcode-org/fedcode-integration
Add workflow to collect latest PURLs from FederatedCode package metadata
2 parents 5062d9f + e31fefe commit 67ea096

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Collect base PURLs for an ecosystem from AboutCode federated package metadata
2+
on:
3+
workflow_call:
4+
inputs:
5+
ecosystem:
6+
description: "Ecosystem for which to collect base PackageURLs (eg. npm)"
7+
required: true
8+
type: string
9+
path:
10+
description: "Path to store collected PURLs (eg. 'data/npm.txt')"
11+
required: true
12+
type: string
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
clone-repos:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Install GitHub CLI
23+
run: |
24+
sudo apt update && sudo apt install -y gh
25+
26+
- name: Fetch repo list
27+
env:
28+
GH_TOKEN: ${{ github.token }}
29+
run: |
30+
mkdir ../repos && cd ../repos
31+
gh repo list aboutcode-data --limit 20000 --json name \
32+
--jq '.[] | select(.name | startswith("purls-${{ inputs.ecosystem }}")) | .name' \
33+
> repos.txt
34+
35+
- name: Shallow clone repos
36+
run: |
37+
cd ../repos
38+
cat repos.txt | xargs -n 1 -P 8 -I {} bash -c '
39+
echo "Cloning {}"
40+
git clone --depth 1 "https://github.com/aboutcode-data/{}.git"
41+
'
42+
- name: Extract base purl from purls.yml
43+
run: |
44+
cd ../repos
45+
find . -type f -name "purls.yml" -exec sed -n '1{ s/^- *//; s/@.*//; p }' {} \; \
46+
> "${{ inputs.ecosystem }}.txt"
47+
48+
- name: Checkout repository
49+
uses: actions/checkout@v4
50+
51+
- name: Commit and push if it changed
52+
run: |-
53+
dest="${{ inputs.path }}"
54+
git config user.name "AboutCode Automation"
55+
git config user.email "[email protected]"
56+
mkdir -p "$(dirname "$dest")" && mv ../repos/${{ inputs.ecosystem }}.txt "$dest"
57+
git add -A
58+
git commit -m "$(echo -e "Sync latest ${{ inputs.ecosystem }} PURLs from FederatedCode\n\nSigned-off-by: AboutCode Automation <[email protected]>")" || exit 0
59+
git push

.github/workflows/sync-purls.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Collect latest PURLs from FederatedCode
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
collect-purls:
13+
strategy:
14+
max-parallel: 1
15+
matrix:
16+
include:
17+
- ecosystem: apk
18+
- ecosystem: cargo
19+
- ecosystem: composer
20+
- ecosystem: conan
21+
- ecosystem: cpan
22+
- ecosystem: cran
23+
- ecosystem: debain
24+
- ecosystem: maven
25+
- ecosystem: npm
26+
- ecosystem: nuget
27+
- ecosystem: pypi
28+
- ecosystem: swift
29+
30+
uses: ./.github/workflows/collect-purls_template.yml
31+
with:
32+
ecosystem: ${{ matrix.ecosystem }}
33+
path: "data/${{ matrix.ecosystem }}.txt"
34+
35+

0 commit comments

Comments
 (0)