Update Releases Feed #43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Releases Feed | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| # - cron: "15 * * * *" # every hour at :15 | |
| - cron: "15 9 * * *" # every day at 09:15 UTC | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # needed to commit updates to releases.json | |
| 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 | |
| steps: | |
| # 1 Checkout the target repo (Repo B) | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| # 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 "AboutCode Automation" | |
| git config user.email "automation@aboutcode.org" | |
| git add website/static/releases.json | |
| git commit -m "$(echo -e "Update releases for ${{ matrix.repo }}\n\nSigned-off-by: AboutCode Automation <automation@aboutcode.org>")" || exit 0 | |
| git pull --rebase origin main | |
| git push | |
| shell: bash |