57
57
((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'))) ||
58
58
(github.repository == 'darvid/python-hyperscan' && contains(github.event.head_commit.message, '[build]'))
59
59
run : |
60
- echo "valid_event=true" >> $GITHUB_OUTPUT
60
+ echo "valid_event=true" >> " $GITHUB_OUTPUT"
61
61
62
62
check_changes :
63
63
name : Build pre-conditions check
@@ -76,36 +76,37 @@ jobs:
76
76
77
77
- name : Check if build is needed
78
78
id : check
79
+ env :
80
+ PR_TITLE : ${{ github.event.pull_request.title }}
79
81
run : |
80
82
if [[ "${{ inputs.force_build || false }}" == "true" ]]; then
81
- echo "should_build=true" >> $GITHUB_OUTPUT
83
+ echo "should_build=true" >> " $GITHUB_OUTPUT"
82
84
echo "Running build because force_build is true"
83
85
exit 0
84
86
fi
85
87
86
88
# Check for [build] tag in commit messages or PR title
87
89
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
88
90
# For PRs, check if PR title contains [build]
89
- PR_TITLE="${{ github.event.pull_request.title }}"
90
91
if [[ "$PR_TITLE" == *"[build]"* ]]; then
91
- echo "should_build=true" >> $GITHUB_OUTPUT
92
+ echo "should_build=true" >> " $GITHUB_OUTPUT"
92
93
echo "Running build because PR title contains [build]"
93
94
exit 0
94
95
fi
95
96
96
97
# Also check all commits in the PR for [build]
97
98
BASE_SHA="${{ github.event.pull_request.base.sha }}"
98
99
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 "")
100
101
if echo "$COMMIT_MSGS" | grep -q "\[build\]"; then
101
- echo "should_build=true" >> $GITHUB_OUTPUT
102
+ echo "should_build=true" >> " $GITHUB_OUTPUT"
102
103
echo "Running build because a commit in the PR contains [build]"
103
104
exit 0
104
105
fi
105
106
else
106
107
# For pushes, check if the head commit message contains [build]
107
108
if [[ "${{ contains(github.event.head_commit.message, '[build]') }}" == "true" ]]; then
108
- echo "should_build=true" >> $GITHUB_OUTPUT
109
+ echo "should_build=true" >> " $GITHUB_OUTPUT"
109
110
echo "Running build because commit message contains [build]"
110
111
exit 0
111
112
fi
@@ -115,7 +116,7 @@ jobs:
115
116
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
116
117
BASE_SHA="${{ github.event.pull_request.base.sha }}"
117
118
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 "")
119
120
else
120
121
# For pushes, use the before/after SHAs or fallback to comparing with parent
121
122
BEFORE_SHA="${{ github.event.before }}"
@@ -126,12 +127,12 @@ jobs:
126
127
CHANGED_FILES=$(git diff --name-only HEAD^ || echo "")
127
128
else
128
129
# 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
131
132
132
133
# 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 "")
135
136
else
136
137
# Fallback to comparing with parent commit
137
138
echo "Cannot find one of the SHAs, falling back to HEAD^"
@@ -144,16 +145,16 @@ jobs:
144
145
RESULT=1
145
146
echo "$CHANGED_FILES" | grep -q -E '^(src/hyperscan/|README.md|CMakeLists.txt|pyproject.toml|MANIFEST.in|cmake/|build_tools/)' || RESULT=$?
146
147
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"
149
150
echo "Running build because relevant files were changed"
150
151
else
151
- echo "should_build=false" >> $GITHUB_OUTPUT
152
+ echo "should_build=false" >> " $GITHUB_OUTPUT"
152
153
echo "Skipping build because no relevant files were changed and commit doesn't have [build] tag"
153
154
fi
154
155
else
155
156
# 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"
157
158
echo "Running build for pull request"
158
159
fi
159
160
0 commit comments