5757 ((github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository) || (github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, vars.RELEASE_PR_BRANCH || 'create-pull-request'))) ||
5858 (github.repository == 'darvid/python-hyperscan' && contains(github.event.head_commit.message, '[build]'))
5959 run : |
60- echo "valid_event=true" >> $GITHUB_OUTPUT
60+ echo "valid_event=true" >> " $GITHUB_OUTPUT"
6161
6262 check_changes :
6363 name : Build pre-conditions check
@@ -76,36 +76,37 @@ jobs:
7676
7777 - name : Check if build is needed
7878 id : check
79+ env :
80+ PR_TITLE : ${{ github.event.pull_request.title }}
7981 run : |
8082 if [[ "${{ inputs.force_build || false }}" == "true" ]]; then
81- echo "should_build=true" >> $GITHUB_OUTPUT
83+ echo "should_build=true" >> " $GITHUB_OUTPUT"
8284 echo "Running build because force_build is true"
8385 exit 0
8486 fi
8587
8688 # Check for [build] tag in commit messages or PR title
8789 if [[ "${{ github.event_name }}" == "pull_request" ]]; then
8890 # For PRs, check if PR title contains [build]
89- PR_TITLE="${{ github.event.pull_request.title }}"
9091 if [[ "$PR_TITLE" == *"[build]"* ]]; then
91- echo "should_build=true" >> $GITHUB_OUTPUT
92+ echo "should_build=true" >> " $GITHUB_OUTPUT"
9293 echo "Running build because PR title contains [build]"
9394 exit 0
9495 fi
9596
9697 # Also check all commits in the PR for [build]
9798 BASE_SHA="${{ github.event.pull_request.base.sha }}"
9899 HEAD_SHA="${{ github.event.pull_request.head.sha }}"
99- COMMIT_MSGS=$(git fetch origin $BASE_SHA $HEAD_SHA && git log --format=%B $ BASE_SHA..$HEAD_SHA || echo "")
100+ COMMIT_MSGS=$(git fetch origin " $BASE_SHA" " $HEAD_SHA" && git log --format=%B "${ BASE_SHA} ..${ HEAD_SHA}" || echo "")
100101 if echo "$COMMIT_MSGS" | grep -q "\[build\]"; then
101- echo "should_build=true" >> $GITHUB_OUTPUT
102+ echo "should_build=true" >> " $GITHUB_OUTPUT"
102103 echo "Running build because a commit in the PR contains [build]"
103104 exit 0
104105 fi
105106 else
106107 # For pushes, check if the head commit message contains [build]
107108 if [[ "${{ contains(github.event.head_commit.message, '[build]') }}" == "true" ]]; then
108- echo "should_build=true" >> $GITHUB_OUTPUT
109+ echo "should_build=true" >> " $GITHUB_OUTPUT"
109110 echo "Running build because commit message contains [build]"
110111 exit 0
111112 fi
@@ -115,7 +116,7 @@ jobs:
115116 if [[ "${{ github.event_name }}" == "pull_request" ]]; then
116117 BASE_SHA="${{ github.event.pull_request.base.sha }}"
117118 HEAD_SHA="${{ github.event.pull_request.head.sha }}"
118- CHANGED_FILES=$(git fetch origin $BASE_SHA $HEAD_SHA && git diff --name-only $ BASE_SHA $ HEAD_SHA || echo "")
119+ CHANGED_FILES=$(git fetch origin " $BASE_SHA" " $HEAD_SHA" && git diff --name-only "${ BASE_SHA}" "${ HEAD_SHA}" || echo "")
119120 else
120121 # For pushes, use the before/after SHAs or fallback to comparing with parent
121122 BEFORE_SHA="${{ github.event.before }}"
@@ -126,12 +127,12 @@ jobs:
126127 CHANGED_FILES=$(git diff --name-only HEAD^ || echo "")
127128 else
128129 # Try to fetch the commits first to make sure they exist
129- git fetch --depth=1 origin $ BEFORE_SHA || true
130- git fetch --depth=1 origin $ AFTER_SHA || true
130+ git fetch --depth=1 origin "${ BEFORE_SHA}" || true
131+ git fetch --depth=1 origin "${ AFTER_SHA}" || true
131132
132133 # Check if both SHAs exist in the repository
133- if git cat-file -e $ BEFORE_SHA 2>/dev/null && git cat-file -e $ AFTER_SHA 2>/dev/null; then
134- CHANGED_FILES=$(git diff --name-only $ BEFORE_SHA $ AFTER_SHA || echo "")
134+ if git cat-file -e "${ BEFORE_SHA}" 2>/dev/null && git cat-file -e "${ AFTER_SHA}" 2>/dev/null; then
135+ CHANGED_FILES=$(git diff --name-only "${ BEFORE_SHA}" "${ AFTER_SHA}" || echo "")
135136 else
136137 # Fallback to comparing with parent commit
137138 echo "Cannot find one of the SHAs, falling back to HEAD^"
@@ -144,16 +145,16 @@ jobs:
144145 RESULT=1
145146 echo "$CHANGED_FILES" | grep -q -E '^(src/hyperscan/|README.md|CMakeLists.txt|pyproject.toml|MANIFEST.in|cmake/|build_tools/)' || RESULT=$?
146147
147- if [[ $RESULT -eq 0 ]]; then
148- echo "should_build=true" >> $GITHUB_OUTPUT
148+ if [[ " $RESULT" -eq 0 ]]; then
149+ echo "should_build=true" >> " $GITHUB_OUTPUT"
149150 echo "Running build because relevant files were changed"
150151 else
151- echo "should_build=false" >> $GITHUB_OUTPUT
152+ echo "should_build=false" >> " $GITHUB_OUTPUT"
152153 echo "Skipping build because no relevant files were changed and commit doesn't have [build] tag"
153154 fi
154155 else
155156 # For pull requests, always build (after checking for [build] tag above)
156- echo "should_build=true" >> $GITHUB_OUTPUT
157+ echo "should_build=true" >> " $GITHUB_OUTPUT"
157158 echo "Running build for pull request"
158159 fi
159160
0 commit comments