Skip to content

Commit 259a174

Browse files
authored
Moved slack notification direct into job instead of dispatch for security (#690)
1 parent b515241 commit 259a174

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

.github/workflows/build-push.yml

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,37 @@ jobs:
7979
runs-on: ubuntu-latest
8080
permissions: read-all
8181
steps:
82-
- name: Trigger 'Slack notification for new theme release' workflow in 'nginx-hugo-theme' repo.
83-
run: |
84-
curl -L \
85-
-X POST \
86-
-H "Accept: application/vnd.github+json" \
87-
-H "Authorization: Bearer ${{ secrets.THEME_SLACK_FLOW_PAT }}" \
88-
-H "X-GitHub-Api-Version: 2022-11-28" \
89-
"https://api.github.com/repos/${{ secrets.OWNER }}/${{ secrets.REPO }}/dispatches" \
90-
-d "{\"event_type\": \"trigger-slack-notification\", \"client_payload\": {\"previewURL\": \"${{ env.PREVIEW_URL }}\", \"author\": \"${{ github.event.client_payload.author}}\", \"tag_name\": \"${{ github.event.client_payload.tag_name }}\", \"release_name\": \"${{ github.event.client_payload.release_name }}\"}}"
82+
- name: Send notification
83+
uses: 8398a7/action-slack@1750b5085f3ec60384090fb7c52965ef822e869e # v3.18.0
84+
with:
85+
status: custom
86+
custom_payload: |
87+
{
88+
username: 'Github',
89+
mention: 'channel',
90+
attachments: [{
91+
title: `New theme release - ${{ github.event.client_payload.release_name }}`,
92+
color: '#009223',
93+
fields: [
94+
{
95+
title: 'Tag',
96+
value: ${{ github.event.client_payload.tag_name }},
97+
short: true
98+
},
99+
{
100+
title: 'Author',
101+
value: ${{ github.event.client_payload.author }},
102+
short: true
103+
},
104+
{
105+
title: 'Preview URL',
106+
value: ${{ env.PREVIEW_URL }},
107+
short: true
108+
}]
109+
}]
110+
}
91111
env:
112+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_FRIENDS_OF_DOCS }}
92113
PREVIEW_URL: ${{ needs.call-docs-build-push.outputs.PREVIEW_URL }}
93114

94115

0 commit comments

Comments
 (0)