-
-
Notifications
You must be signed in to change notification settings - Fork 3
60 lines (53 loc) · 1.98 KB
/
collect-purls_template.yml
File metadata and controls
60 lines (53 loc) · 1.98 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
name: Collect base PURLs for an ecosystem from AboutCode federated package metadata
on:
workflow_call:
inputs:
ecosystem:
description: "Ecosystem for which to collect base PackageURLs (eg. npm)"
required: true
type: string
path:
description: "Path to store collected PURLs (eg. 'data/npm.txt')"
required: true
type: string
permissions:
contents: write
jobs:
clone-repos:
runs-on: ubuntu-latest
steps:
- name: Install GitHub CLI
run: |
sudo apt update && sudo apt install -y gh
- name: Fetch repo list
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir ../repos && cd ../repos
gh repo list aboutcode-data --limit 20000 --json name \
--jq '.[] | select(.name | startswith("purls-${{ inputs.ecosystem }}")) | .name' \
> repos.txt
- name: Shallow clone repos
run: |
cd ../repos
cat repos.txt | xargs -n 1 -P 8 -I {} bash -c '
echo "Cloning {}"
git clone --depth 1 "https://github.com/aboutcode-data/{}.git"
'
- name: Extract base purl from purls.yml
run: |
cd ../repos
find . -type f -name "purls.yml" -exec sed -n '1{ s/^- *//; s/@.*//; p }' {} \; | sort \
> "${{ inputs.ecosystem }}.txt"
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Commit and push if it changed
run: |-
dest="${{ inputs.path }}"
git config user.name "AboutCode Automation"
git config user.email "automation@aboutcode.org"
git pull
mkdir -p "$(dirname "$dest")" && mv ../repos/${{ inputs.ecosystem }}.txt "$dest"
git add -A
git commit -m "$(echo -e "Sync latest ${{ inputs.ecosystem }} PURLs from FederatedCode\n\nSigned-off-by: AboutCode Automation <automation@aboutcode.org>")" || exit 0
git push