Skip to content

Commit

Permalink
ci: sync pipeline (#1)
Browse files Browse the repository at this point in the history
Add a workflow to sync the cloudnative-pg api to this repository.

Signed-off-by: Francesco Canovai <[email protected]>
  • Loading branch information
fcanovai authored Oct 3, 2024
1 parent e27c8bc commit 51cdf26
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/sync.yaml
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 }}

0 comments on commit 51cdf26

Please sign in to comment.