-
Notifications
You must be signed in to change notification settings - Fork 3
66 lines (64 loc) · 2.83 KB
/
check-openapi-change.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# 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