@@ -187,6 +187,20 @@ jobs:
187187 PubkeyAcceptedKeyTypes +ssh-rsa
188188 IdentityFile ~/.ssh/id_rsa
189189
190+ - name : " Get ticket from JSON lookup table"
191+ if : ${{ (vars.ISSUEID == true) }}
192+ uses : lfit/releng-reusable-workflows/.github/actions/json-key-value-lookup-action@main
193+ with :
194+ json : ${{ inputs.issue_id_lookup_json }}
195+ key : ${{ env.SET_ISSUE_ID }}
196+ shell : bash
197+ # yamllint disable rule:line-length
198+ run : |
199+ set -x
200+ if [ -n "${{ env.SET_ISSUE_ID }}" ]; then
201+ echo "SET_ISSUE_ID=${{ env.SET_ISSUE_ID }}" >> "$GITHUB_ENV"
202+ fi
203+
190204 - name : Setup Gerrit remote
191205 if : env.PROJECT_REPO_GERRIT != ''
192206 shell : bash
@@ -249,6 +263,7 @@ jobs:
249263 echo "FAIL: Change-Id not created, exit job!"
250264 exit 1
251265 fi
266+ # issue_id="$(git log --format="%(trailers:key=Issue-ID,valueonly,separator=%x2C)" -n1)"
252267 git checkout ${{ env.GERRIT_BRANCH }}
253268 done
254269 git log -n3
@@ -293,6 +308,8 @@ jobs:
293308 - name: Squash commits into a single commit
294309 shell: bash
295310 if: ${{ (env.PR_COMMITS > 0) && (inputs.SUBMIT_SINGLE_COMMITS == false) }}
311+ env:
312+ SET_ISSUE_ID: ${{ env.SET_ISSUE_ID }}
296313 # yamllint disable rule:line-length
297314 run: |
298315 set -x
@@ -309,6 +326,12 @@ jobs:
309326 git log -v --format=%B --reverse "HEAD..HEAD@{1}" | grep -E "^(Signed-off-by)" > signed-off-by.txt || true
310327 git log -v --format=%B --reverse "HEAD..HEAD@{1}" | grep -Ev "^(Signed-off-by|Change-Id)" > commit-msg.txt
311328
329+ if [ -n "${{ env.SET_ISSUE_ID }}" ]; then
330+ echo "Issue-ID: $SET_ISSUE_ID" > issue-id.txt
331+ fi
332+
333+ # git log -v --format=%B --reverse "HEAD..HEAD@{1}" | grep -Ev "^(Issue-ID)" > issue-id.txt
334+
312335 # capture author info
313336 git show -s --pretty=format:"%an <%ae>" "HEAD..HEAD@{1}" > author-info.txt
314337 if [[ -s author-info.txt ]]; then
@@ -338,13 +361,21 @@ jobs:
338361 commit_message+="signed-off-by-final.txt"
339362 fi
340363
341- # shellcheck disable=SC2086
342- git commit -s -v --no-edit --author "$author" -m "$(cat $commit_message)"
364+ if [ -n ${{ env.SET_ISSUE_ID }} ]; then
365+ issue_id="Issue-ID: ${{ env.SET_ISSUE_ID }}"
366+ # shellcheck disable=SC2086
367+ git commit -s -v --no-edit --author "$author" --trailer "$issue_id" -m "$(cat $commit_message)"
368+ elif
369+ # shellcheck disable=SC2086
370+ git commit -s -v --no-edit --author "$author" -m "$(cat $commit_message)"
371+ fi
343372 git log -n2
344373
345374 - name: Overwrite commit message with PR tittle and body
346375 if: ${{ (github.event_name == 'pull_request_target') && (env.PR_COMMITS > 0) && (inputs.USE_PR_AS_COMMIT == true) && (inputs.SUBMIT_SINGLE_COMMITS == false) }}
347376 shell: bash
377+ env:
378+ SET_ISSUE_ID: ${{ env.SET_ISSUE_ID }}
348379 # yamllint disable rule:line-length
349380 run: |
350381 set -x
@@ -367,7 +398,13 @@ jobs:
367398 fi
368399
369400 if [[ -f pr_commit.txt ]] && [[ ($pr_body_length -gt 0) ]] && [[ ($pr_tittle_length -gt 0) ]]; then
370- git commit -s -v --amend --author "$author" --no-edit -F "pr_commit.txt"
401+ if [ -n ${{ env.SET_ISSUE_ID }} ]; then
402+ # extract Issue-id from commit/pr footer
403+ issue_id="Issue-ID: ${{ env.SET_ISSUE_ID }}"
404+ git commit -s -v --amend --author "$author" --trailer "$issue_id" --no-edit -F "pr_commit.txt"
405+ else
406+ git commit -s -v --amend --author "$author" --no-edit -F "pr_commit.txt"
407+ fi
371408 git log -n2
372409 fi
373410 env:
0 commit comments