4

I am having an issue with Github Actions workflow using the Databricks Repos API. We want the API call in the Git Action to bring the Repo in our Databricks Repos Top-level folder to the latest version on a merge into the main branch.

The Github Actions workflow that we have set up is:

on:
  pull_request:
    types:
      - closed

jobs:
  if_merged:
    if: github.event.pull_request.merged == true
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: |
          export DATABRICKS_TOKEN=databricks_token_here
          curl PATCH --header "Authorization: Bearer $DATABRICKS_TOKEN" \
          https://<databricks-instance>/api/2.0/repos/{repo_id}?branch=main

Upon merging, the Github Action is successful. But when going back to the Repo in Databricks, the updated files are not there unless we pull in the Databricks Repos UI.

Is there something that I am missing from the Actions workflow?

Alex Ott
  • 80,552
  • 8
  • 87
  • 132
Jorge
  • 392
  • 3
  • 14

1 Answers1

3

yes, you have an error - payload with branch name should be the JSON, not part of URL. Here is working code:

curl -s -n -X PATCH  "$DATABRICKS_HOST/api/2.0/repos/$STAGING_REPOS_ID" \
  -H "Authorization: Bearer $DATABRICKS_TOKEN" -d '{"branch": "main"}'

P.S. You can also use databricks-cli with databricks repos update command as it's shown here. Main advantage - you can use path to repo instead of repo ID.

Alex Ott
  • 80,552
  • 8
  • 87
  • 132
  • Thanks for the response @Alex. This helped us figure it out, but we did have to remove the \ from the JSON: '{"branch": "main"}' – Jorge Apr 06 '22 at 19:54
  • Ah, sorry - used the wrong quotes around body - fixed in answer. In my original code I had a variable there – Alex Ott Apr 06 '22 at 20:20