Add screenshots from headless browser tests #14
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Docker Image | |
on: | |
push: | |
tags: | |
- 'v*.*.*' # Triggers on version tags | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
services: | |
chrome: | |
image: selenium/standalone-chrome | |
options: >- | |
--shm-size 2g | |
ports: | |
- 4444:4444 | |
http_server: | |
image: nginx:alpine | |
ports: | |
- 5500:80 | |
volumes: | |
- ${{ github.workspace }}:/usr/share/nginx/html # Mount the code directory | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' # Specify your desired Python version | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r ./devtools/screenshots/requirements.txt | |
- name: Wait for server to start | |
run: | | |
# Wait for the server to respond | |
curl -s http://localhost:5500/ | |
for i in {1..10}; do | |
if curl -s http://localhost:5500/ > /dev/null; then | |
echo "Server is up!" | |
break | |
fi | |
echo "Waiting for server..." | |
sleep 5 # Wait 5 seconds before trying again | |
done | |
- name: Run tests | |
run: | | |
cd ./devtools/screenshots | |
python main.py | |
- name: Add and commit screenshots | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add public/screenshots/* | |
git add manifest.json | |
git commit -m "Add screenshots from headless browser tests" || echo "No changes to commit" | |
git push origin HEAD:main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use the GitHub token for authentication | |
build: | |
runs-on: ubuntu-latest | |
needs: test # Ensure this job waits for the previous job to finish | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Extract version from tag | |
id: version | |
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
- name: Build Docker Image | |
run: | | |
docker build -t ghcr.io/toomanyfiles/tmf-timetable-frontend:${{ env.VERSION }} \ | |
-t ghcr.io/toomanyfiles/tmf-timetable-frontend:latest . | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push Docker Image with version and latest tags | |
run: | | |
docker push ghcr.io/toomanyfiles/tmf-timetable-frontend:${{ env.VERSION }} | |
docker push ghcr.io/toomanyfiles/tmf-timetable-frontend:latest |