Skip to content

Commit

Permalink
SlackNotifications
Browse files Browse the repository at this point in the history
  • Loading branch information
akshayp7 committed Feb 25, 2024
1 parent f6af9bf commit b045d82
Showing 1 changed file with 20 additions and 28 deletions.
48 changes: 20 additions & 28 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Name of the GitHub Actions workflow
name: Playwright Github Actions

# Define when to trigger this workflow
on:
push:
branches:
Expand All @@ -10,62 +8,56 @@ on:
branches:
- main

# Define the jobs to run in this workflow
jobs:
# Define a job named 'build'
build:
# Specify the operating system for this job
runs-on: ubuntu-latest
env:
SLACK_WEBHOOK_URL: ${{secrets.SLACK_WEBHOOK_URL}}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

# Define the steps to execute in this job
steps:
# Step to checkout the source code from the repository
- name: Checkout code
uses: actions/checkout@v2

# Step to set up the Node.js version
- name: Install node js v20
uses: actions/setup-node@v2
with:
node-version: "20"

# Step to install Node.js dependencies
- name: Install dependencies
run: npm ci

# Step to install Chrome browser for Playwright
- name: Install Chrome browser for Playwright
run: npx playwright install chrome

# Step to run tests with qa as environment variable similarly we can define qa|dev|qaApi|devApi
- name: Run tests
run: npm run test:serial
env:
npm_config_ENV: "qa"

# Step to wait for the job to complete
- name: Wait for job completion
# Adjust the wait time as needed
run: sleep 30s
# This step should always run, even if previous steps fail
if: always()

# Step to zip html-report folder
- name: Zip HTML report
run: zip -r html-report.zip html-report
# This step should always run, even if previous steps fail
if: always()

- name: Send Slack notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_CHANNEL: "#playwright-test-reports"
SLACK_USERNAME: GitHub Actions
SLACK_TITLE: Playwright Tests Completed
SLACK_TEXT: "Playwright tests have completed. Here is the HTML zip report."
SLACK_FILE: ./html-report.zip
# This step should always run, even if previous steps fail
if: always()
- name: Upload HTML report as artifact
uses: actions/upload-artifact@v2
with:
name: html-report
path: html-report.zip

- name: Send Slack notification with artifact link
uses: peaceiris/actions-slack@v2
with:
title: Playwright tests have completed
description: |
Playwright tests have completed successfully. HTML report is attached as an artifact.
You can download the report from the following link:
[Download HTML report](${{ github.server_url }}/${{ github.repository }}/actions/artifacts/html-report)
author_name: GitHub Actions
color: good
footer: ${{ github.event_name }}
author_icon: https://avatars.githubusercontent.com/u/44036562
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}

0 comments on commit b045d82

Please sign in to comment.