Skip to content

Commit

Permalink
Handle case when triggered event is a new branch or a tag push (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
neel-astro authored Oct 29, 2024
1 parent 0c310b4 commit cf22781
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,19 @@ runs:
branch=$(echo "${GITHUB_REF#refs/heads/}")
echo "Branch pushed to: $branch"
git fetch origin $branch
files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})
echo "Files changed: $files"
DBT_DEPLOY=false
# case when the triggered event is a new branch or tag creation, we would need to deploy the dbt project because we cannot determine that it does not need to be deployed
if [[ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]]
then
DBT_DEPLOY=true
files=()
else
files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})
echo "files changed: $files"
fi
for file in $files; do
if [[ $file =~ ^"${{ inputs.root-folder }}".* ]]; then
echo $file is part of configured root folder, so would be triggering a dbt deploy
Expand Down Expand Up @@ -355,12 +364,21 @@ runs:
branch=$(echo "${GITHUB_REF#refs/heads/}")
echo "Branch pushed to: $branch"
git fetch origin $branch
files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})
echo "files changed: $files"
DAGS_ONLY_DEPLOY=false
SKIP_IMAGE_OR_DAGS_DEPLOY=true
# case when the triggered event is a new branch or tag creation, we would need to deploy the image because we cannot determine that it does not need to be deployed
if [[ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]]
then
DAGS_ONLY_DEPLOY=false
SKIP_IMAGE_OR_DAGS_DEPLOY=false
files=()
else
files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})
echo "files changed: $files"
fi
for file in $files; do
if [[ $file =~ ^"${{ inputs.root-folder }}".* ]]; then
echo $file is part of the input root folder
Expand Down

0 comments on commit cf22781

Please sign in to comment.