Skip to content

Commit b8d1086

Browse files
Merge pull request #17 from packagist/send-commit-info
Reorganize hook calls and send base branch head commit info
2 parents b8b726f + 0d5166c commit b8d1086

1 file changed

Lines changed: 54 additions & 2 deletions

File tree

action.yml

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ runs:
3434
shell: "bash"
3535
run: "${GITHUB_ACTION_PATH}/bin/composer_version_check.sh ${{ github.event.client_payload.requirements.minimumComposerVersion }}"
3636

37+
- name: Store commit info
38+
id: commit_info
39+
run: |
40+
git log -1 --format="HASH=%H" >> $GITHUB_OUTPUT
41+
git log -1 --format="AUTHOR=%an" >> $GITHUB_OUTPUT
42+
git log -1 --format="MESSAGE=%s" >> $GITHUB_OUTPUT
43+
shell: bash
44+
3745
- name: Configure Composer authentication
3846
shell: "bash"
3947
if: ${{ github.event.client_payload.composerAuthentication.type == 'environment' }}
@@ -95,9 +103,53 @@ runs:
95103

96104
- name: Call webhook from Private Packagist to create the pull request
97105
shell: bash
98-
run: "curl -fsSL -X POST -u ${{ github.event.client_payload.webhook.authentication.username }}:${{ github.event.client_payload.webhook.authentication.password }} --header \"Content-Type: application/json\" --data '{\"runId\":\"${{github.run_id}}\",\"numberOfChangedFiles\":\"${{ steps.number_of_changed_files.outputs.COUNT }}\",\"versions\":{\"ciScriptVersion\":\"1.4.0\"}}' ${{ github.event.client_payload.webhook.executedUrl }}"
106+
env:
107+
RUN_ID: ${{ github.run_id }};
108+
CHANGED_FILES: ${{ steps.number_of_changed_files.outputs.COUNT }}
109+
COMMIT_HASH: ${{ steps.commit_info.outputs.HASH }},
110+
COMMIT_AUTHOR: ${{ steps.commit_info.outputs.AUTHOR }},
111+
COMMIT_MESSAGE: ${{ steps.commit_info.outputs.MESSAGE }}
112+
CI_VERSION: "1.5.0"
113+
run: |
114+
jq -n '{
115+
"runId": env.RUN_ID,
116+
"numberOfChangedFiles": env.CHANGED_FILES,
117+
"commitInfo": {
118+
"hash": env.COMMIT_HASH,
119+
"author": env.COMMIT_AUTHOR,
120+
"message": env.COMMIT_MESSAGE
121+
},
122+
"versions": {
123+
"ciScriptVersion": env.CI_VERSION
124+
}
125+
}' | curl -fsSL -X POST \
126+
-u "${{ github.event.client_payload.webhook.authentication.username }}:${{ github.event.client_payload.webhook.authentication.password }}" \
127+
--header "Content-Type: application/json" \
128+
--data @- \
129+
"${{ github.event.client_payload.webhook.executedUrl }}"
99130
100131
- name: Call webhook from Private Packagist to notify about build failure
101132
shell: bash
133+
env:
134+
RUN_ID: ${{ github.run_id }}
135+
COMMIT_HASH: ${{ steps.commit_info.outputs.HASH }}
136+
COMMIT_AUTHOR: ${{ steps.commit_info.outputs.AUTHOR }}
137+
COMMIT_MESSAGE: ${{ steps.commit_info.outputs.MESSAGE }}
138+
CI_VERSION: 1.5.0
102139
if: ${{ failure() }}
103-
run: "curl -fsSL -X POST -u ${{ github.event.client_payload.webhook.authentication.username }}:${{ github.event.client_payload.webhook.authentication.password }} --header \"Content-Type: application/json\" --data '{\"runId\":\"${{github.run_id}}\",\"versions\":{\"ciScriptVersion\":\"1.4.0\"}}' ${{ github.event.client_payload.webhook.errorUrl }}"
140+
run: |
141+
jq -n '{
142+
"runId": env.RUN_ID,
143+
"commitInfo": {
144+
"hash": env.COMMIT_HASH,
145+
"author": env.COMMIT_AUTHOR,
146+
"message": env.COMMIT_MESSAGE
147+
},
148+
"versions": {
149+
"ciScriptVersion": env.CI_VERSION
150+
}
151+
}' | curl -fsSL -X POST \
152+
-u "${{ github.event.client_payload.webhook.authentication.username }}:${{ github.event.client_payload.webhook.authentication.password }}" \
153+
--header "Content-Type: application/json" \
154+
--data @- \
155+
"${{ github.event.client_payload.webhook.errorUrl }}"

0 commit comments

Comments
 (0)