94 lines
3.0 KiB
YAML
Executable File
94 lines
3.0 KiB
YAML
Executable File
name: Playwright Tests
|
|
on:
|
|
push:
|
|
branches: [main, master]
|
|
pull_request:
|
|
branches: [main, master]
|
|
jobs:
|
|
test:
|
|
environment: Build
|
|
timeout-minutes: 60
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: oven-sh/setup-bun@v2
|
|
- name: Get installed Playwright version
|
|
id: playwright-version
|
|
run: |
|
|
export VER=$(bun --print "require('./bun.lock').workspaces[''].devDependencies['@playwright/test'].slice(1)")
|
|
echo "PLAYWRIGHT_VERSION=$VER" >> $GITHUB_ENV
|
|
- name: Cache playwright binaries
|
|
uses: actions/cache@v4
|
|
id: playwright-cache
|
|
with:
|
|
path: |
|
|
~/.cache/ms-playwright
|
|
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
|
|
- name: Install dependencies
|
|
run: bun i --frozen-lockfile
|
|
- name: Install Playwright Browsers
|
|
run: bun x playwright install --with-deps
|
|
- name: Tailscale
|
|
uses: tailscale/github-action@v4
|
|
with:
|
|
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
|
|
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
|
|
tags: tag:ci
|
|
if: ${{ vars.NO_TAILSCALE != 'true' }}
|
|
- name: Run Playwright tests
|
|
run: bun x --bun playwright test
|
|
env:
|
|
DATABASE_URL: ${{ secrets.DATABASE_URL }}
|
|
BETTER_AUTH_SECRET: ${{ secrets.DATABASE_URL }}
|
|
BASE_URL: ${{ vars.BASE_URL }}
|
|
deploy:
|
|
# needs: test
|
|
if: github.event_name == 'push'
|
|
environment: Deploy
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.dgnr.us
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITEA_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
push: true
|
|
tags: |
|
|
git.dgnr.us/${{ github.repository }}:latest
|
|
git.dgnr.us/${{ github.repository }}:${{ github.sha }}
|
|
cache-from: type=registry,ref=git.dgnr.us/${{ github.repository }}:buildcache
|
|
cache-to: type=registry,ref=git.dgnr.us/${{ github.repository }}:buildcache,mode=max
|
|
|
|
- name: Deploy on server
|
|
uses: appleboy/ssh-action@v1
|
|
with:
|
|
host: 100.75.220.33
|
|
username: dmgnr
|
|
password: none # Tailscale authentication
|
|
port: 22
|
|
script: |
|
|
cd buzzy
|
|
echo "${{ secrets.GITEA_TOKEN }}" | docker login git.dgnr.us -u ${{ github.actor }} --password-stdin
|
|
docker compose pull
|
|
docker compose up -d --remove-orphans
|
|
docker system prune -f
|
|
|
|
# Verify deployment
|
|
sleep 5
|
|
if docker compose ps | grep -q "Up"; then
|
|
echo "Deployment successful"
|
|
else
|
|
echo "Deployment failed"
|
|
exit 1
|
|
fi
|