Skip to content

Commit

Permalink
handle case when triggered event is new branch or tag push
Browse files Browse the repository at this point in the history
  • Loading branch information
neel-astro committed Oct 28, 2024
1 parent 359775e commit 0d49564
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 @@ -308,10 +308,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, then we would need to deploy the dbt project to be on the safe side
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 @@ -351,12 +360,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, then we would need to deploy the image to be on the safe side
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 0d49564

Please sign in to comment.