Skip to content

Build Run and Test Website Crawl #76

Build Run and Test Website Crawl

Build Run and Test Website Crawl #76

name: Build Run and Test Website Crawl
on:
workflow_dispatch:
inputs:
A11Y_ENGINE_BRANCH:
description: 'Oobee Branch (master, other)'
required: true
default: 'master'
A11Y_SCAN_URL:
description: 'Website URL'
required: true
default: 'https://'
A11Y_SCANNER:
description: 'Scanner (website, sitemap)'
required: true
default: 'website'
A11Y_SCAN_MAX_NUM_PAGES:
description: 'Maximum Number of Pages to Scan'
required: true
default: '10'
A11Y_SCAN_MAX_CONCURRENCY:
description: 'Maximum Number of Concurrent Page Scans'
required: true
default: '10'
A11Y_SCAN_SCREENSHOTS:
description: 'Include screenshots (screenshots, none)'
required: true
default: 'screenshots'
A11Y_SCAN_FOLLOW_ROBOTS:
description: 'Crawler adhere to robots.txt (yes, no)'
required: true
default: 'no'
A11Y_SCAN_STRATEGY:
description: 'Crawler adhere to pages matching exact hostname or same parent domain (same-hostname, same-domain)'
required: true
default: 'same-domain'
USERNAME:
description: "Your name (for telemetry purposes)"
required: false
EMAIL:
description: "Email address (for telemetry purposes)"
required: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Get Public IP Address
run:
curl https://ipinfo.io
- name: Check if email is valid or empty
run: |
email="${{ inputs.EMAIL }}"
echo "Email provided: $email"
valid_email_regex='^.+@.+\..+$'
echo "Validating with regex: $valid_email_regex"
status="$(if [ -z "$email" ]; then echo "Empty"; elif [[ $email =~ $valid_email_regex ]]; then echo "Valid"; else echo "Invalid"; fi)"
if [[ "$status" == "Invalid" ]]; then
echo "Invalid email provided. Workflow failed."
exit 1
fi
# Proceed with steps if EMAIL is valid or empty
- name: Use provided name and email or defaults
run: |
if [[ -z "${{ inputs.EMAIL }}" ]]; then
final_email="${{ github.actor }}@users.noreply.github.com"
else
final_email="${{ inputs.EMAIL }}"
fi
username="${{ inputs.USERNAME || github.actor }}"
echo "final_email=$final_email" >> $GITHUB_ENV
echo "username=$username" >> $GITHUB_ENV
# Use $final_email and $username in subsequent steps
- name: Checkout code
uses: actions/checkout@master
with:
repository: "GovTechSG/oobee"
ref: "${{ github.event.inputs.A11Y_ENGINE_BRANCH }}"
- name: Build and run Docker container
run: |
# Build your Docker image (replace 'oobee' and 'Dockerfile' with your image name and Dockerfile path)
docker build -t oobee .
# Run the Docker container (adjust any options as needed)
docker run -dit --name oobee-container --add-host=docs.google.com:0.0.0.0 --add-host=assets.wogaa.sg:0.0.0.0 oobee
# Ensure the Docker container is running before running the next step
continue-on-error: true
- name: Start accessibility scan in Docker container
run: |
# Execute a webisite crawl
docker exec -e OOBEE_VERBOSE=true oobee-container npm run cli -- -c "${{ github.event.inputs.A11Y_SCANNER }}" -u "${{ github.event.inputs.A11Y_SCAN_URL }}" -p "${{ github.event.inputs.A11Y_SCAN_MAX_NUM_PAGES }}" -t "${{ github.event.inputs.A11Y_SCAN_MAX_CONCURRENCY }}" -a "${{ github.event.inputs.A11Y_SCAN_SCREENSHOTS }}" -r "${{ github.event.inputs.A11Y_SCAN_FOLLOW_ROBOTS }}" -s "${{ github.event.inputs.A11Y_SCAN_STRATEGY}}" -k "${{ env.username }}:${{ env.final_email }}" -b chromium || true
- name: Print errors
run: |
docker exec oobee-container cat errors.txt || true
- name: Print logs
run: |
docker exec oobee-container cat logs/*/*.txt || true
- name: Copy Results from Docker Container
run: docker cp oobee-container:/app/results ./results
- name: Zip Results
run: zip -r results.zip ./results
- name: Upload Zip File
uses: actions/upload-artifact@v4
with:
name: results
path: results.zip
- name: Cleanup Docker container
run: |
# Stop and remove the Docker container
docker stop oobee-container
docker rm oobee-container