name: core-api-test
on:
  pull_request:
    paths:
      - 'apis/**'
      - 'pkg/oam/**'
      - "hack/apis/**"
    branches:
      - master
      - release-*

permissions:
  contents: read

jobs:
  core-api-test:
    runs-on: ubuntu-22.04
    steps:
      - name: Set up Go 1.19
        uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
        env:
          GO_VERSION: '1.19'
        with:
          go-version: ${{ env.GO_VERSION }}
        id: go

      - name: Check out code into the Go module directory
        uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9

      - name: Get the version
        id: get_version
        run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

      - name: Test build kubevela-core-api
        env:
          VERSION: ${{ steps.get_version.outputs.VERSION }}
          COMMIT_ID: ${{ github.sha }}
        run: |
          bash ./hack/apis/clientgen.sh
          bash ./hack/apis/sync.sh test