feat: new CI workflow

This commit is contained in:
2026-03-26 21:34:39 +07:00 Unverified
parent 42cfbffb58
commit 7fe363f5cb
+22 -85
View File
@@ -1,93 +1,30 @@
name: Playwright Tests
name: Build and Push Image
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
branches:
- main
- dev
jobs:
test:
environment: Build
timeout-minutes: 60
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- name: Get installed Playwright version
id: playwright-version
- name: Checkout
uses: actions/checkout@v4
- name: Login to Gitea Registry
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
echo "${{ secrets.GITEA_TOKEN }}" | docker login \
git.dgnr.us \
-u ${{ gitea.actor }} \
--password-stdin
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Image
run: |
docker build -t git.dgnr.us/${{ gitea.repository }}:latest .
- 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
- name: Push Image
run: |
docker push git.dgnr.us/${{ gitea.repository }}:latest