Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action fails if run on a tag push event #82

Closed
dbsanfte opened this issue Sep 26, 2024 · 2 comments · Fixed by #90
Closed

Action fails if run on a tag push event #82

dbsanfte opened this issue Sep 26, 2024 · 2 comments · Fixed by #90

Comments

@dbsanfte
Copy link

The Github Action fails if run on a tag push event, even with checkout disabled:

Branch pushed to: refs/tags/v1.0.0
From https://github.com/***/my-project
 * tag               v1.0.0     -> FETCH_HEAD
fatal: bad object 0000000000000000000000000000000000000000

The error seems to be in the script here, because github.event.before on a tag resolves to 00000....:

files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})

cd ./
  branch=$(echo "${GITHUB_REF#refs/heads/}")
  echo "Branch pushed to: $branch"
  git fetch origin $branch
  files=$(git diff --name-only 0000000000000000000000000000000000000000 26a5079efe4455002e65374e71fbc24cf5bf3633)
  echo "files changed: $files"

We are using the release-please plugin to push our DAGs to Prod on the back of a tag push. I will work around this for now with custom shell I guess. Would be good if you can fix.

@dbsanfte
Copy link
Author

dbsanfte commented Sep 26, 2024

I patched the v0.6 version of the action with this on a local fork:

    - name: Get Deployment Type
      run: |
        cd ${{ inputs.root-folder }}
        branch=$(echo "${GITHUB_REF#refs/heads/}")
        echo "Our ref is: $branch"
        
        # DS: handle no `github.event.before` on tags push event:
        if [[ "$branch" == refs/tags/* ]]
        then
          dags_only=0
        else
          git fetch origin $branch
          files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})
          echo "files changed: $files"
          dags_only=1
  
          for file in $files; do
            if [[ $file != *"dags/"* ]]; then
              echo $file is not a DAG, triggering a full image build
              dags_only=0
              break
            fi
          done
        fi

        if [[ ${{steps.dag-deploy-enabled.outputs.DAG_DEPLOY_ENABLED}} == false ]]; then
          dags_only=0
        fi

        if [[ ${{steps.deployment-preview.outputs.SKIP_DEPLOY}} == true ]]; then
          # skip all deploy steps
          dags_only=2
        fi

        if [[ ${{ inputs.deploy-image }} == true ]]; then
          # make sure image and DAGs deploys because deploy-image is true
          dags_only=0
        fi

        echo "DAGS_ONLY=$dags_only" >> $GITHUB_OUTPUT
      shell: bash
      id: deployment-type

In case anyone else needs a quick fix.

@neel-astro
Copy link
Collaborator

The fix for this has been included in v0.8.0 release, thanks for raising the issue and helping with identifying gaps in the project ❤ 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants