detected-horreum-openapi-change #17
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 workflow will fetch the new openapi from the provided branch of https://github.com/Hyperfoil/Horreum and based on | |
# that it will re-generate the Horreum raw client and check the build/tests are still working. | |
# It could be tested running `gh act workflow_dispatch -e ./test/gha_workflows/workflow_dispatch_event_example.json`. | |
name: Update Horreum auto-generated client | |
on: | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: Branch or tag of https://github.com/Hyperfoil/Horreum | |
required: true | |
# this event should be triggered by Horreum repo using peter-evans/repository-dispatch@v2 | |
repository_dispatch: | |
types: [ detected-horreum-openapi-change ] | |
env: | |
GO_VERSION: "1.21" | |
jobs: | |
check-openapi-change: | |
runs-on: ubuntu-latest | |
env: | |
FORCE_COLOR: "1" | |
PRE_COMMIT_COLOR: "always" | |
steps: | |
- name: Fetch Horreum branch | |
id: fetch-horreum-branch | |
run: | | |
if [ "${{ github.event_name }}" = "repository_dispatch" ]; then | |
echo "horreum_branch=${{ github.event.client_payload.branch }}" >> $GITHUB_OUTPUT | |
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
echo "horreum_branch=${{ github.event.inputs.branch }}" >> $GITHUB_OUTPUT | |
else | |
echo "Unknown event: ${{ github.event_name }}" | |
exit 1 | |
fi | |
- name: Fetch client branch | |
id: fetch-client-branch | |
run: | | |
if [ "${{ steps.fetch-horreum-branch.outputs.horreum_branch }}" = "master" ]; then | |
echo "horreum_client_branch=main" >> $GITHUB_OUTPUT | |
else | |
echo "horreum_client_branch=${{ steps.fetch-horreum-branch.outputs.horreum_branch }}" >> $GITHUB_OUTPUT | |
fi | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ steps.fetch-client-branch.outputs.horreum_client_branch }} | |
persist-credentials: false | |
- name: Setup Go ${{ env.GO_VERSION }} | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Clean | |
run: make clean | |
- name: Build | |
run: make HORREUM_BRANCH=${{ steps.fetch-horreum-branch.outputs.horreum_branch }} build | |
- name: Create Pull Request | |
uses: gr2m/create-or-update-pull-request-action@v1 | |
env: | |
# Need another secret, less privilages | |
GITHUB_TOKEN: ${{ secrets.RH_PERF_BOT_TOKEN }} | |
with: | |
title: Update Horreum raw client on ${{ steps.fetch-client-branch.outputs.horreum_client_branch }} | |
body: > | |
There is a change in the Horreum openapi spec for branch ${{ steps.fetch-horreum-branch.outputs.horreum_branch }}. Verify that there are no breaking changes. | |
branch: detected-horreum-openapi-change-${{ steps.fetch-client-branch.outputs.horreum_client_branch }} | |
commit-message: Horreum client updated |