1+ # Name of the GitHub Actions workflow
12name : Playwright Github Actions
23
4+ # Define when to trigger this workflow
35on :
46 push :
57 branches :
810 branches :
911 - main
1012
13+ # Define the jobs to run in this workflow
1114jobs :
15+ # Define a job named 'build'
1216 build :
17+ # Specify the operating system for this job
1318 runs-on : ubuntu-latest
1419 env :
1520 SLACK_WEBHOOK_URL : ${{secrets.SLACK_WEBHOOK_URL}}
1621
22+ # Define the steps to execute in this job
1723 steps :
24+ # Step to checkout the source code from the repository
1825 - name : Checkout code
1926 uses : actions/checkout@v2
2027
28+ # Step to set up the Node.js version
2129 - name : Install node js v20
2230 uses : actions/setup-node@v2
2331 with :
2432 node-version : " 20"
2533
34+ # Step to install Node.js dependencies
2635 - name : Install dependencies
2736 run : npm ci
2837
38+ # Step to install Chrome browser for Playwright
2939 - name : Install Chrome browser for Playwright
3040 run : npx playwright install chrome
3141
42+ # Step to run tests with qa as environment variable similarly we can define qa|dev|qaApi|devApi
3243 - name : Run tests
3344 run : npm run test:serial
3445 env :
3546 npm_config_ENV : " qa"
3647
48+ # Step to wait for the job to complete
3749 - name : Wait for job completion
50+ # Adjust the wait time as needed
3851 run : sleep 30s
52+ # This step should always run, even if previous steps fail
3953 if : always()
4054
55+ # Step to zip html-report folder
4156 - name : Zip HTML report
4257 run : zip -r html-report.zip html-report
58+ # This step should always run, even if previous steps fail
4359 if : always()
4460
45- - name : Send Slack notification with HTML report
46- uses : rtCamp/action-slack@v3
47- with :
48- text : " Playwright tests have completed. HTML report is attached."
49- channel : " #playwright-test-reports"
50- attachments : |
51- [{
52- "color": "good",
53- "blocks": [
54- {
55- "type": "section",
56- "text": {
57- "type": "mrkdwn",
58- "text": "Playwright HTML Report"
59- }
60- }
61- ],
62- "files": [
63- {
64- "path": "./html-report.zip"
65- }
66- ]
67- }]
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()
0 commit comments