Skip to content

Commit 7be5c2c

Browse files
committed
Add gchat notification for distro release artifact
1 parent 2f7fe9b commit 7be5c2c

File tree

2 files changed

+124
-7
lines changed

2 files changed

+124
-7
lines changed

.github/workflows/gh-hosted-eclipse-distro-build.yml

+73
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ jobs:
5757
run: |
5858
echo "${{ secrets.GPG_PRIVATE_KEY }}" > gpg.asc
5959
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --batch --yes --passphrase-fd 0 --import gpg.asc
60+
- name: Project Version
61+
id: project-version
62+
run: |
63+
current_version=`./mvnw help:evaluate -Dexpression="project.version" -q -DforceStdout`
64+
version=${current_version%%-*}
65+
echo "version=$version" >> $GITHUB_OUTPUT
6066
- name: Build Eclipse Distro
6167
env:
6268
# MAVEN_OPTS: -Dmaven.wagon.httpconnectionManager.ttlSeconds=40 -Dmaven.wagon.http.retryHandler.count=10 -Daether.connector.http.connectionMaxTtl=40 -Dhttp.keepAlive=false -Dhttpclient.retry-max=30 -Dorg.eclipse.ecf.provider.filetransfer.httpclient.retrieve.readTimeout=1800000 -Dorg.eclipse.ecf.provider.filetransfer.httpclient4.retrieve.readTimeout=1800000 -Dorg.eclipse.ecf.provider.filetransfer.retrieve.readTimeout=1800000 -Dorg.eclipse.ecf.provider.filetransfer.retrieve.retryAttempts=30 -Dorg.eclipse.equinox.p2.transport.ecf.retry=10
@@ -140,6 +146,7 @@ jobs:
140146
id: ${{ inputs.eclipse_profile }}-${{ inputs.build_type }}-${{ github.run_id }}
141147
dist_path: ${{ steps.s3-paths.outputs.dist_path }}
142148
p2_path: ${{ steps.s3-paths.outputs.p2_path }}
149+
version: ${{ steps.project-version.outputs.version }}
143150

144151

145152
sign-win-distros:
@@ -310,6 +317,72 @@ jobs:
310317
cloudflare_zone_id: ${{ secrets.CLOUDFLARE_ZONE_ID }}
311318
cloudflare_cache_token: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }}
312319

320+
gchat-message:
321+
needs: [ eclipse-distro-build, sign-win-distros, sign-osx-distros ]
322+
if: ${{ inputs.build_type == 'release' }}
323+
name: Send GChat message
324+
runs-on: ubuntu-latest
325+
steps:
326+
- name: Google Chat Notification
327+
run: |
328+
echo "P2 Update Site: ${DOWNLOAD_URL_ROOT}/${{ needs.eclipse-distro-build.outputs.p2_path }}"
329+
downloads_html="sts4-distro-downloads-${{ inputs.eclipse_profile }}.txt"
330+
rm -f ./downloads_html
331+
s3_url=s3://${AWS_S3_BUCKET}/${{ needs.eclipse-distro-build.outputs.dist_path }}
332+
files=`aws s3 cp ${s3_url} . --recursive --exclude "*" --include "spring-tool-suite-4*.zip" --include "spring-tool-suite-4*.dmg" --include "spring-tool-suite-4*.self-extracting.jar" --include "spring-tool-suite-4*.tar.gz" --exclude "*/*" --dryrun`
333+
s3_url_prefix="s3://${AWS_S3_BUCKET}"
334+
s3_url_prefix_length=${#s3_url_prefix}
335+
for file in $files
336+
do
337+
if [[ "$file" =~ ^"${s3_url_prefix}" ]]; then
338+
download_url=${DOWNLOAD_URL_ROOT}${file:$s3_url_prefix_length}
339+
filename=${file:${#s3_url}+1}
340+
echo $download_url
341+
echo $filename
342+
echo "<li><a href=${download_url}>${filename}</a></li>" >> $downloads_html
343+
fi
344+
done
345+
distro_links=`cat ./$downloads_html`
346+
rm -f ./$downloads_html
347+
348+
build_type=${{ inputs.build_type }}
349+
build_type=${build_type^}
350+
eclipse_profile=${{ inputs.eclipse_profile }}
351+
eclipse_version=${eclipse_profile:1:1}.${eclipse_profile:2}
352+
353+
curl --location --request POST '${{ secrets.TOOLS_TEAM_GCHAT_WEBHOOK_URL }}' \
354+
--header 'Content-Type: application/json' \
355+
--data-raw "{
356+
\"cards\": [
357+
{
358+
\"header\": {
359+
\"title\": \"STS ${{ needs.eclipse-distro-build.outputs.version }} ${build_type}\",
360+
\"subtitle\": \"Eclipse ${eclipse_version}\",
361+
\"imageUrl\": \"https://avatars.githubusercontent.com/u/317776?s=48&amp;v=4\",
362+
},
363+
\"sections\": [
364+
{
365+
\"widgets\": [
366+
{
367+
\"keyValue\": {
368+
\"topLabel\": \"P2 Update Site\",
369+
\"content\": \"<a href=${DOWNLOAD_URL_ROOT}/${{ needs.eclipse-distro-build.outputs.p2_path }}>${DOWNLOAD_URL_ROOT}/${{ needs.eclipse-distro-build.outputs.p2_path }}</a>\"
370+
}
371+
},
372+
{
373+
\"keyValue\": {
374+
\"topLabel\": \"Distributions\",
375+
\"content\": \"${distro_links}\",
376+
\"contentMultiline\": true
377+
}
378+
}
379+
]
380+
}
381+
]
382+
}
383+
]
384+
}"
385+
313386
cleanup:
314387
needs: [ eclipse-distro-build, sign-win-distros, sign-osx-distros ]
315388
if: ${{ always() }}

.github/workflows/test-eclipse-distro-gchat-notification.yml

+51-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ name: Test Eclipse Distro GChat Message
33
on:
44
workflow_dispatch:
55
inputs:
6+
version:
7+
description: version
8+
required: true
9+
default: 4.24.0
10+
type: string
611
eclipse_profile:
712
description: Eclipse profile 'e429' etc
813
required: true
@@ -13,12 +18,12 @@ on:
1318
required: true
1419
default: 'release'
1520
type: string
16-
p2-path:
21+
p2_path:
1722
description: p2 path
1823
default: 'release/TOOLS/sts4/update/4.24.0.RELEASE/e4.32'
1924
required: true
2025
type: string
21-
dist-path:
26+
dist_path:
2227
description: distro path
2328
default: 'release/STS4/4.24.0.RELEASE/dist/e4.32'
2429
required: true
@@ -40,8 +45,8 @@ jobs:
4045
- name: Google Chat Notification
4146
run: |
4247
echo "P2 Update Site: ${DOWNLOAD_URL_ROOT}/${{ inputs.p2_path }}"
43-
downloads_md="sts4-distro-downloads-${{ inputs.eclipse_profile }}.txt"
44-
rm -f ./$downloads_md
48+
downloads_html="sts4-distro-downloads-${{ inputs.eclipse_profile }}.txt"
49+
rm -f ./downloads_html
4550
s3_url=s3://${AWS_S3_BUCKET}/${{ inputs.dist_path }}
4651
files=`aws s3 cp ${s3_url} . --recursive --exclude "*" --include "spring-tool-suite-4*.zip" --include "spring-tool-suite-4*.dmg" --include "spring-tool-suite-4*.self-extracting.jar" --include "spring-tool-suite-4*.tar.gz" --exclude "*/*" --dryrun`
4752
s3_url_prefix="s3://${AWS_S3_BUCKET}"
@@ -51,9 +56,48 @@ jobs:
5156
if [[ "$file" =~ ^"${s3_url_prefix}" ]]; then
5257
download_url=${DOWNLOAD_URL_ROOT}${file:$s3_url_prefix_length}
5358
filename=${file:${#s3_url}+1}
54-
echo '<a href="${download_url}">${filename}</a>' >> $$downloads_md
59+
echo $download_url
60+
echo $filename
61+
echo "<li><a href=${download_url}>${filename}</a></li>" >> $downloads_html
5562
fi
5663
done
57-
cat ./$$downloads_md
58-
rm -f ./$downloads_md
64+
distro_links=`cat ./$downloads_html`
65+
rm -f ./$downloads_html
66+
67+
build_type=${{ inputs.build_type }}
68+
build_type=${build_type^}
69+
eclipse_profile=${{ inputs.eclipse_profile }}
70+
eclipse_version=${eclipse_profile:1:1}.${eclipse_profile:2}
5971
72+
curl --location --request POST '${{ secrets.TOOLS_TEAM_GCHAT_WEBHOOK_URL }}' \
73+
--header 'Content-Type: application/json' \
74+
--data-raw "{
75+
\"cards\": [
76+
{
77+
\"header\": {
78+
\"title\": \"STS ${{ inputs.version }} ${build_type}\",
79+
\"subtitle\": \"Eclipse ${eclipse_version}\",
80+
\"imageUrl\": \"https://avatars.githubusercontent.com/u/317776?s=48&amp;v=4\",
81+
},
82+
\"sections\": [
83+
{
84+
\"widgets\": [
85+
{
86+
\"keyValue\": {
87+
\"topLabel\": \"P2 Update Site\",
88+
\"content\": \"<a href=${DOWNLOAD_URL_ROOT}/${{ inputs.p2_path }}>${DOWNLOAD_URL_ROOT}/${{ inputs.p2_path }}</a>\"
89+
}
90+
},
91+
{
92+
\"keyValue\": {
93+
\"topLabel\": \"Distributions\",
94+
\"content\": \"${distro_links}\",
95+
\"contentMultiline\": true
96+
}
97+
}
98+
]
99+
}
100+
]
101+
}
102+
]
103+
}"

0 commit comments

Comments
 (0)