88 required : false
99 type : string
1010 default : ' '
11+ workflow_dispatch :
12+ inputs :
13+ environment :
14+ description : ' Environment to deploy to'
15+ type : choice
16+ required : true
17+ default : ' staging'
18+ options :
19+ - staging
20+ - production
1121
1222jobs :
1323 check-changes :
@@ -20,13 +30,20 @@ jobs:
2030 uses : actions/checkout@v3
2131 with :
2232 ref : ${{ inputs.ref || github.ref }}
23- fetch-depth : 2
33+ fetch-depth : 0
2434
2535 - name : Check for changes in dependency files
2636 id : check-changes
2737 run : |
28- # For manual triggers or workflow calls, check if files have changed in the last commit
29- CHANGED_FILES=$(git diff --name-only HEAD^ HEAD)
38+ # For manual triggers or workflow calls, check if files have changed
39+ if git rev-parse --verify HEAD^1 >/dev/null 2>&1; then
40+ # If we have a parent commit, compare with it
41+ CHANGED_FILES=$(git diff --name-only HEAD^1 HEAD)
42+ else
43+ # If this is the first commit or we're on a different branch
44+ # List all tracked files
45+ CHANGED_FILES=$(git ls-tree -r --name-only HEAD)
46+ fi
3047 # Define the pattern for dependency-related files
3148 DEPENDENCY_PATTERN="^package\.json$|^yarn\.lock$|^apps\/api\/package\.json$"
3249 DEPENDENCY_PATTERN="$DEPENDENCY_PATTERN|^packages\/(auth|common|config|contracts|core|plugin|utils)\/.*package\.json$"
5673 needs : check-changes
5774 if : needs.check-changes.outputs.changes_detected == 'true'
5875 runs-on : ubuntu-latest
59- # Determine environment based on ref (if tag or dev-dspot branch)
60- environment : ${{ startsWith(github.ref, 'refs/tags/v') && 'production' || 'staging' }}
76+ # Determine environment based on manual input or ref
77+ environment : ${{ inputs.environment || ( startsWith(github.ref, 'refs/tags/v') && 'production' || 'staging') }}
6178 permissions :
6279 contents : read
6380 id-token : write
0 commit comments