build improvement exp #1
This commit is contained in:
@@ -1,49 +1,97 @@
|
||||
name: Playwright Tests
|
||||
on:
|
||||
push:
|
||||
branches: [ main, master ]
|
||||
branches: [main, master]
|
||||
pull_request:
|
||||
branches: [ main, master ]
|
||||
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: # Or as an environment variable
|
||||
DATABASE_URL: ${{ secrets.DATABASE_URL }}
|
||||
BETTER_AUTH_SECRET: ${{ secrets.DATABASE_URL }}
|
||||
BASE_URL: ${{ vars.BASE_URL }}
|
||||
- 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: # Or as an environment variable
|
||||
DATABASE_URL: ${{ secrets.DATABASE_URL }}
|
||||
BETTER_AUTH_SECRET: ${{ secrets.DATABASE_URL }}
|
||||
BASE_URL: ${{ vars.BASE_URL }}
|
||||
# - uses: actions/upload-artifact@v4
|
||||
# if: ${{ !cancelled() }}
|
||||
# with:
|
||||
# name: playwright-report
|
||||
# path: playwright-report/
|
||||
# retention-days: 30
|
||||
deploy:
|
||||
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: ${{ secrets.SSH_HOST }}
|
||||
username: dmgnr
|
||||
port: ${{ secrets.SSH_PORT }}
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user