trigger compilation result for a configRelease dataform on merge in main branch

110 Views Asked by At

I want to trigger a compilation result of a releaseConfig dataform when I merge to main branch. I know that I can schedule the compilation but I prefer to trigger the compilation once my branch is merged.

I'm using github git provider.. the call to the api dataform to compile a releaseconfig looks like this:

    {
"createCompilationResult": {
    "call": "http.post",
    "args": {
        "url": "${\"https://dataform.googleapis.com/v1beta1/\" + repository + \"/compilationResults\"}",
        "auth": {
            "type": "OAuth2"
        },
        "body": {
            "releaseConfig": "${repository + \"/releaseConfigs/\" + \"${releaseConfigName}\"}"
        }
    },
    "result": "compilationResult"
}

}

Any ideas please ?

Thank you

1

There are 1 best solutions below

0
On

To trigger a compilation result of releaseConfig dataform when you merge to the main branch using the GitHub Actions. Utilizing the GitHub actions, you can automate the process as follows:

  1. Create a new workflow YAML file (.yml) under the .github/workflows directory in your repository. This file will define the workflow steps for triggering the compilation.

  2. Add the following content to the file:

yaml
name: Dataform Compilation

on:
  pull_request:
    types:
      - closed
  jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Set up Node.js
        uses: actions/setup-node@v2
        with:
          node-version: 14

      - name: Install dependencies
        run: npm install

      - name: Trigger Dataform Compilation
        run: |
          # Make the API call to trigger the compilation
          # Replace the placeholders with actual values
          # Example API call:
          # curl -X POST -H "Authorization: Bearer <your_token>" -H "Content-Type

Replace <your_token>, <your_release_config_path>, and <your_repository> with the actual values. This workflow will trigger the compilation when a pull request is closed, which corresponds to merging the pull request into the main branch.