Skip to content

pr_ci_playwright_e2e #37

pr_ci_playwright_e2e

pr_ci_playwright_e2e #37

name: pr_ci_playwright_e2e
on:
workflow_dispatch:
jobs:
frontend:
name: Run PR Frontend Check
runs-on: ubuntu-latest
environment: dev
steps:
- name: cleanup old checkout
run: chmod +w -R ${GITHUB_WORKSPACE}; rm -rf ${GITHUB_WORKSPACE}/*;
- name: Checkout
uses: actions/checkout@v4
- name: Clean up any existing containers
run: |
docker stop $(docker ps -aq) || true
docker rm $(docker ps -aq) || true
- name: Check Port Availability
run: |
! nc -z localhost 3000 && \
! nc -z localhost 8000 && \
! nc -z localhost 5432
- name: Run Docker Compose
run: docker compose --env-file .env.dev up --build -d
- name: Check Docker Container Logs
run: docker compose --env-file .env.dev logs
- name: Setup Node environment
uses: actions/setup-node@v4
with:
node-version: 20
- name: Clean Yarn cache
working-directory: ./frontend
run: |
sudo yarn cache clean
- name: Install dependencies via Yarn
working-directory: ./frontend
run: |
sudo yarn install
- name: Install Playwright Browsers
working-directory: ./frontend
run: |
sudo yarn playwright install --with-deps
- name: Wait for web server to be ready
working-directory: ./frontend
run: |
yarn wait-on http://localhost:3000
- name: Run Playwright tests
working-directory: ./frontend
run: |
sudo yarn playwright test --reporter=html
- name: Ensure gh-pages branch exists
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git fetch origin gh-pages
if git rev-parse --verify origin/gh-pages; then
git checkout gh-pages
git reset --hard origin/gh-pages
else
git checkout --orphan gh-pages
git rm -rf .
echo "# GitHub Pages" > index.html
git add index.html
git commit -m "Initial commit"
git push origin gh-pages
fi
- name: Deploy Playwright Report to gh-pages
if: always()
run: |
# Configuring git
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
# Clone the repository to the gh-pages branch
git clone --branch=gh-pages https://github.com/${{ github.repository }} gh-pages || (git clone https://github.com/${{ github.repository }} gh-pages && cd gh-pages && git checkout --orphan gh-pages)
cd gh-pages
# Copying the Playwright report to the gh-pages branch
rm -rf ./*
cp -r ../frontend/playwright-report/* .
# Committing and pushing the changes
git add .
git commit -m "Update Playwright report"
git push origin gh-pages --force
- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: frontend/playwright-report/
retention-days: 30