Skip to content

Commit 60e510f

Browse files
committed
Report e2e test result to Discord
1 parent 58b73b1 commit 60e510f

File tree

1 file changed

+48
-5
lines changed

1 file changed

+48
-5
lines changed

.github/workflows/e2e.yml

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: E2E Tests
22

33
on:
44
schedule:
5-
- cron: '0 0 * * *'
5+
- cron: "0 0 * * *"
66
push:
77
branches:
88
- main
@@ -11,6 +11,7 @@ env:
1111
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
1212
PLAYWRIGHT_BROWSERS_PATH: 0
1313
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
1415

1516
permissions:
1617
id-token: write # This is required for requesting the JWT
@@ -48,7 +49,7 @@ jobs:
4849
else
4950
previous_version=""
5051
fi
51-
52+
5253
if [ "$latest_version" != "$previous_version" ]; then
5354
echo "Versions are different. Continuing the pipeline."
5455
else
@@ -61,14 +62,13 @@ jobs:
6162
previousNextVersion: ${{ steps.get_latest_version.outputs.LATEST_VERSION }}
6263
cacheKey: ${{ steps.cache-previous.outputs.cache-primary-key }}
6364

64-
# If the event is push (merged and pushed into main) or if
65+
# If the event is push (merged and pushed into main) or if
6566
# the latest Nextjs version hasn't been tested, run the Playwright tests
6667
e2e:
6768
needs: check_next_version
6869
if: github.event_name == 'push' || needs.check_next_version.outputs.skip != 'true'
6970
runs-on: ubuntu-latest
7071
steps:
71-
7272
- name: Checkout code
7373
uses: actions/checkout@v3
7474

@@ -154,9 +154,52 @@ jobs:
154154
- name: Store Latest Version
155155
run: |
156156
echo "${{ needs.check_next_version.outputs.previousNextVersion }}" > previous_version.txt
157-
157+
158158
- name: Cache Previous Version
159159
uses: actions/cache/save@v3
160160
with:
161161
path: previous_version.txt
162162
key: ${{ needs.check_next_version.outputs.cacheKey }}
163+
164+
#############################
165+
# Report status to Discord
166+
#############################
167+
- name: Report success
168+
if: success()
169+
run: |
170+
curl -X POST "$DISCORD_WEBHOOK" \
171+
-H "Content-Type: application/json" \
172+
-d '{
173+
"username": "OpenNext E2E Test",
174+
"avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
175+
"embeds": [
176+
{
177+
"description": "Test succeeded — [view results](https://github.com/${{ github.repository }}/actions/runs/${{github.run_id}})",
178+
"color": 3061373,
179+
"footer": {
180+
"text": "Woah! So cool!",
181+
"icon_url": "https://i.imgur.com/u2ENxCk.png"
182+
}
183+
}
184+
]
185+
}'
186+
187+
- name: Report failure
188+
if: failure()
189+
run: |
190+
curl -X POST "$DISCORD_WEBHOOK" \
191+
-H "Content-Type: application/json" \
192+
-d '{
193+
"username": "OpenNext E2E Test",
194+
"avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
195+
"embeds": [
196+
{
197+
"description": "Test failed — [view results](https://github.com/${{ github.repository }}/actions/runs/${{github.run_id}})",
198+
"color": 14687834,
199+
"footer": {
200+
"text": "Hmmm...",
201+
"icon_url": "https://i.imgur.com/QeXzqIy.png"
202+
}
203+
}
204+
]
205+
}'

0 commit comments

Comments
 (0)