Skip to content

Commit 0cc5fa0

Browse files
authored
Send Slack notifications only when versions file PR is created (#4534)
Currently, the Slack message is sent on every successful job run which is incorrect. The message should be sent only when a new PR is created.
1 parent 292c332 commit 0cc5fa0

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

.github/workflows/bump-agent-versions.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ else
1717
git diff -p
1818
git add ".agent-versions.json"
1919

20-
nl=$'\n' # otherwise the new line character is not recognized properly
21-
commit_desc="This file is used for picking agent versions in integration tests.${nl}${nl}The file's content is based on responses from https://www.elastic.co/api/product_versions and https://snapshots.elastic.co${nl}${nl}The current update is generated based on the following requirements:${nl}${nl}\`\`\`json${nl}${version_requirements}${nl}\`\`\`"
20+
nl=$'\n' # otherwise the new line character is not recognized properly
21+
commit_desc="This file is used for picking agent versions in integration tests.${nl}${nl}The file's content is based on responses from https://www.elastic.co/api/product_versions and https://snapshots.elastic.co${nl}${nl}The current update is generated based on the following requirements:${nl}${nl}\`\`\`json${nl}${version_requirements}${nl}\`\`\`"
2222

23-
git commit -m "[$GITHUB_REF_NAME][Automation] Update .agent-versions.json" -m "$commit_desc"
23+
git commit -m "[$GITHUB_REF_NAME][Automation] Update .agent-versions.json" -m "$commit_desc"
2424
git push --set-upstream origin "update-agent-versions-$GITHUB_RUN_ID"
2525
gh pr create \
2626
--base "$GITHUB_REF_NAME" \
@@ -31,4 +31,5 @@ else
3131
--label 'skip-changelog' \
3232
--label 'backport-skip' \
3333
--repo $GITHUB_REPOSITORY
34+
echo "::set-output name=pr::true" # set step output for notifications
3435
fi

.github/workflows/bump-agent-versions.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
install-only: true
4141

4242
- name: Update versions file
43+
id: update
4344
env:
4445
GH_TOKEN: ${{ env.GITHUB_TOKEN }}
4546
run: ./.github/workflows/bump-agent-versions.sh
@@ -53,7 +54,7 @@ jobs:
5354
message: ":traffic_cone: Elastic Agent versions file update failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
5455
channel: "#ingest-notifications"
5556

56-
- if: ${{ success() }}
57+
- if: ${{ success() && steps.update.output.pr == true}}
5758
uses: elastic/apm-pipeline-library/.github/actions/slack-message@current
5859
with:
5960
url: ${{ secrets.VAULT_ADDR }}

0 commit comments

Comments
 (0)