generated from cloudnative-pg/cnpg-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a workflow to sync the cloudnative-pg api to this repository. Signed-off-by: Francesco Canovai <[email protected]>
- Loading branch information
Showing
1 changed file
with
70 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# This workflow will sync the API types from the cloudnative-pg repository to the API repository, and | ||
# tidy the go.mod file. | ||
# It is supposed to be triggered by a repository_dispatch event whenever the cloudnative-pg api is updated, | ||
# but can also be triggered manually using the "Sync API" workflow_dispatch event. | ||
|
||
name: Sync API | ||
|
||
on: | ||
workflow_dispatch: | ||
repository_dispatch: | ||
types: [ sync-api ] | ||
|
||
jobs: | ||
sync: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout API repository | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.REPO_PAT }} | ||
|
||
- name: Checkout cloudnative-pg repository | ||
uses: actions/checkout@v4 | ||
with: | ||
path: cloudnative-pg | ||
repository: cloudnative-pg/cloudnative-pg | ||
sparse-checkout: api/v1 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: cloudnative-pg/go.mod | ||
|
||
- name: Copy types files from cloudnative-pg | ||
run: | | ||
rm -rf pkg/api/v1 | ||
mkdir -p pkg/api/v1 | ||
cp cloudnative-pg/api/v1/*_types.go pkg/api/v1 | ||
cp cloudnative-pg/api/v1/groupversion_info.go pkg/api/v1 | ||
cp cloudnative-pg/api/v1/zz_*.go pkg/api/v1 | ||
cp cloudnative-pg/go.mod cloudnative-pg/go.sum . | ||
go mod tidy | ||
go vet ./... | ||
# We want to prevent the "include administrators" branch protection from blocking the commit, | ||
# but it should be usually there to avoid accidental pushes to main. | ||
- name: Temporarily disable "include administrators" branch protection | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
id: disable_include_admins | ||
uses: benjefferies/[email protected] | ||
with: | ||
access_token: ${{ secrets.REPO_PAT }} | ||
branch: main | ||
enforce_admins: false | ||
|
||
- uses: EndBug/add-and-commit@v9 | ||
with: | ||
author_name: CloudNativePG Automated Updates | ||
author_email: [email protected] | ||
message: 'chore: sync API' | ||
add: pkg/api/v1 go.mod go.sum | ||
|
||
- name: Enable "include administrators" branch protection | ||
uses: benjefferies/[email protected] | ||
if: ${{ always() && github.ref == 'refs/heads/main' }} | ||
with: | ||
access_token: ${{ secrets.REPO_PAT }} | ||
branch: main | ||
enforce_admins: ${{ steps.disable_include_admins.outputs.initial_status }} |