diff --git a/.github/workflows/collect-purls_template.yml b/.github/workflows/collect-purls_template.yml new file mode 100644 index 0000000..5e98cf8 --- /dev/null +++ b/.github/workflows/collect-purls_template.yml @@ -0,0 +1,59 @@ +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 }' {} \; \ + > "${{ inputs.ecosystem }}.txt" + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Commit and push if it changed + run: |- + dest="${{ inputs.path }}" + git config user.name "AboutCode Automation" + git config user.email "automation@aboutcode.org" + 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 ")" || exit 0 + git push \ No newline at end of file diff --git a/.github/workflows/sync-purls.yml b/.github/workflows/sync-purls.yml new file mode 100644 index 0000000..c33cc0e --- /dev/null +++ b/.github/workflows/sync-purls.yml @@ -0,0 +1,35 @@ +name: Collect latest PURLs from FederatedCode + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' + +permissions: + contents: write + +jobs: + collect-purls: + strategy: + max-parallel: 1 + matrix: + include: + - ecosystem: apk + - ecosystem: cargo + - ecosystem: composer + - ecosystem: conan + - ecosystem: cpan + - ecosystem: cran + - ecosystem: debain + - ecosystem: maven + - ecosystem: npm + - ecosystem: nuget + - ecosystem: pypi + - ecosystem: swift + + uses: ./.github/workflows/collect-purls_template.yml + with: + ecosystem: ${{ matrix.ecosystem }} + path: "data/${{ matrix.ecosystem }}.txt" + + \ No newline at end of file