-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: generate releases.json on release event
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. Also ignore .github/releases.json file on pull request event as an action in a workflow run can't trigger a new workflow run anyway. See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#example-using-more-than-one-event Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
61 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: releases-json | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
release: | ||
types: | ||
- released | ||
pull_request: | ||
paths-ignore: | ||
- '.github/releases.json' | ||
|
||
jobs: | ||
generate: | ||
uses: crazy-max/.github/.github/workflows/releases-json.yml@2a596c917a8ad3e6203ae99b777148525a2e00d5 | ||
with: | ||
repository: docker/buildx | ||
artifact_name: releases-json | ||
filename: releases.json | ||
secrets: inherit | ||
|
||
open-pr: | ||
runs-on: ubuntu-22.04 | ||
if: github.event_name == 'release' | ||
needs: | ||
- generate | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Download | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: releases-json | ||
path: .github | ||
- | ||
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: "github: 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 |
This file contains 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