Skip to content

Commit

Permalink
ci: generate releases.json on release event
Browse files Browse the repository at this point in the history
We are currently using the GitHub API in our setup-buildx-action
to check for latest and tagged releases to make sure they exist
before download. But this requires using a token to avoid
rate-limit. It's fine for public runners but GHES runners don't
have the `github.token` populated automatically. They need to
create a PAT.

This PR will solve this issue by generating and pushing a
`releases.json` file in this repo when we publish a GitHub Release
that will then be fetched through `raw.githubusercontent.com`
endpoint on `setup-buildx-action` repo. This endpoint is better
served for our purpose with 5000 requests per hour compared to the
GitHub API endpoint that is limited to 60 requests per hour (unauth)
and 1000 request per hour when authenticated.

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Jan 28, 2023
1 parent a718d07 commit 1c75ba5
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/releases-json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: releases-json

on:
release:
types:
- released

env:
RELEASES_JSON_PATH: .github/releases.json

jobs:
generate:
uses: crazy-max/.github/.github/workflows/releases-json.yml@5d21ab1b5b9e9bebca815e4d92b8310b4f8765ae
with:
repository: docker/buildx
secrets: inherit

releases-json:
runs-on: ubuntu-22.04
needs:
- generate
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Create .github/releases.json file
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
await fs.writeFileSync('${{ env.RELEASES_JSON_PATH }}', `${{ needs.generate.outputs.releases }}`);
-
name: Upload releases.json
uses: actions/upload-artifact@v3
with:
name: releases-json
path: .github/releases.json
if-no-files-found: error
-
name: Commit changes
run: |
git add -A .
-
name: Create PR
uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04
with:
base: master
branch: releases-json/${{ github.event.release.name }}
commit-message: "update .github/releases.json"
signoff: true
delete-branch: true
title: "Update `.github/releases.json`"
body: |
Update `.github/releases.json` to keep in sync with GitHub Releases.
draft: false

0 comments on commit 1c75ba5

Please sign in to comment.