|
| 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 |
0 commit comments