1- # Name of the GitHub Actions workflow
21name : Playwright Github Actions
32
4- # Define when to trigger this workflow
53on :
64 push :
75 branches :
108 branches :
119 - main
1210
13- # Define the jobs to run in this workflow
1411jobs :
15- # Define a job named 'build'
1612 build :
17- # Specify the operating system for this job
1813 runs-on : ubuntu-latest
1914 env :
20- SLACK_WEBHOOK_URL : ${{secrets.SLACK_WEBHOOK_URL}}
15+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
2116
22- # Define the steps to execute in this job
2317 steps :
24- # Step to checkout the source code from the repository
2518 - name : Checkout code
2619 uses : actions/checkout@v2
2720
28- # Step to set up the Node.js version
2921 - name : Install node js v20
3022 uses : actions/setup-node@v2
3123 with :
3224 node-version : " 20"
3325
34- # Step to install Node.js dependencies
3526 - name : Install dependencies
3627 run : npm ci
3728
38- # Step to install Chrome browser for Playwright
3929 - name : Install Chrome browser for Playwright
4030 run : npx playwright install chrome
4131
42- # Step to run tests with qa as environment variable similarly we can define qa|dev|qaApi|devApi
4332 - name : Run tests
4433 run : npm run test:serial
4534 env :
4635 npm_config_ENV : " qa"
4736
48- # Step to wait for the job to complete
4937 - name : Wait for job completion
50- # Adjust the wait time as needed
5138 run : sleep 30s
52- # This step should always run, even if previous steps fail
5339 if : always()
5440
55- # Step to zip html-report folder
5641 - name : Zip HTML report
5742 run : zip -r html-report.zip html-report
58- # This step should always run, even if previous steps fail
5943 if : always()
6044
61- - name : Send Slack notification
62- uses : rtCamp/action-slack-notify@v2
63- env :
64- SLACK_WEBHOOK : ${{ secrets.SLACK_WEBHOOK_URL }}
65- SLACK_CHANNEL : " #playwright-test-reports"
66- SLACK_USERNAME : GitHub Actions
67- SLACK_TITLE : Playwright Tests Completed
68- SLACK_TEXT : " Playwright tests have completed. Here is the HTML zip report."
69- SLACK_FILE : ./html-report.zip
70- # This step should always run, even if previous steps fail
71- if : always()
45+ - name : Upload HTML report as artifact
46+ uses : actions/upload-artifact@v2
47+ with :
48+ name : html-report
49+ path : html-report.zip
50+
51+ - name : Send Slack notification with artifact link
52+ uses : peaceiris/actions-slack@v2
53+ with :
54+ title : Playwright tests have completed
55+ description : |
56+ Playwright tests have completed successfully. HTML report is attached as an artifact.
57+ You can download the report from the following link:
58+ [Download HTML report](${{ github.server_url }}/${{ github.repository }}/actions/artifacts/html-report)
59+ author_name : GitHub Actions
60+ color : good
61+ footer : ${{ github.event_name }}
62+ author_icon : https://avatars.githubusercontent.com/u/44036562
63+ webhook-url : ${{ secrets.SLACK_WEBHOOK_URL }}
0 commit comments