From 2d5726cb208c5a32f86ca8a3f5e03fc5e54109f2 Mon Sep 17 00:00:00 2001 From: sakethsomaraju Date: Tue, 10 Dec 2024 11:47:33 +0530 Subject: [PATCH] Handle case when triggered event is a manual workflow_dispatch (#97) Co-authored-by: Saketh Somaraju --- action.yaml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/action.yaml b/action.yaml index d729914..e090cf1 100644 --- a/action.yaml +++ b/action.yaml @@ -315,13 +315,14 @@ runs: 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=() + # case when the triggered event is a manual workflow dispatch or 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 + GITHUB_EVENT_BEFORE=${{ github.event.before }} + GITHUB_EVENT_AFTER=${{ github.event.after }} + if [[ "$GITHUB_EVENT_BEFORE" == "0000000000000000000000000000000000000000" || -z $GITHUB_EVENT_BEFORE && -z $GITHUB_EVENT_AFTER ]]; then + DBT_DEPLOY=true + files=() else - files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }}) + files=$(git diff --name-only $GITHUB_EVENT_BEFORE $GITHUB_EVENT_AFTER) echo "files changed: $files" fi @@ -368,14 +369,15 @@ runs: 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=() + # case when the triggered event is a manual workflow dispatch or 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 + GITHUB_EVENT_BEFORE=${{ github.event.before }} + GITHUB_EVENT_AFTER=${{ github.event.after }} + if [[ "$GITHUB_EVENT_BEFORE" == "0000000000000000000000000000000000000000" || -z $GITHUB_EVENT_BEFORE && -z $GITHUB_EVENT_AFTER ]]; then + DAGS_ONLY_DEPLOY=false + SKIP_IMAGE_OR_DAGS_DEPLOY=false + files=() else - files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }}) + files=$(git diff --name-only $GITHUB_EVENT_BEFORE $GITHUB_EVENT_AFTER) echo "files changed: $files" fi