chore(ci/cd): adjust workflows ci/cd files to work with actions/cache

This commit is contained in:
Ilia Mashkov
2025-12-30 19:37:25 +03:00
parent 7c94622b95
commit 53e3d6985b
4 changed files with 53 additions and 172 deletions

View File

@@ -1,59 +1,32 @@
name: Build name: Build
on: on:
push: push:
branches: branches: [main, develop]
- main
- develop
pull_request: pull_request:
branches: branches: [main, develop]
- main
- develop
workflow_dispatch: workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs: jobs:
build: build:
name: Build Project
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - uses: actions/checkout@v4
uses: actions/checkout@v4
- name: Setup Node.js - name: Setup Node
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: '20' node-version: '20'
cache: 'yarn' cache: 'yarn'
- name: Install dependencies - name: Install
run: yarn install --frozen-lockfile run: yarn install --frozen-lockfile --prefer-offline
- name: Run SvelteKit sync - name: Build Svelte App
run: yarn svelte-kit sync
- name: Build project
run: yarn build run: yarn build
env:
NODE_ENV: production
- name: Upload build artifacts - name: Upload Artifacts
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: build-artifacts name: build-artifacts
path: | path: dist/
.svelte-kit/output
.svelte-kit/build
retention-days: 7 retention-days: 7
- name: Verify build (Preview)
run: |
yarn preview &
PREVIEW_PID=$!
sleep 5
curl -f http://localhost:4173 || exit 1
kill $PREVIEW_PID

View File

@@ -1,127 +1,42 @@
name: Deploy name: Deploy Pipeline
on: on:
push: push:
branches: branches: [main]
- main
workflow_dispatch: workflow_dispatch:
inputs: inputs:
environment: environment:
description: 'Deployment environment' description: 'Target'
required: true required: true
default: 'production' default: 'production'
type: choice type: choice
options: options: [staging, production]
- staging
- production
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs: jobs:
deploy: pipeline:
name: Deploy to ${{ github.event.inputs.environment || 'production' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.environment || 'production' }}
# Only deploy after successful linting, testing, and building
needs: [lint, test, build]
steps: steps:
- name: Checkout repository - uses: actions/checkout@v4
uses: actions/checkout@v4
- name: Setup Node.js - name: Setup Node
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: '20' node-version: '20'
cache: 'yarn' cache: 'yarn'
- name: Install dependencies - name: Install
run: yarn install --frozen-lockfile run: yarn install --frozen-lockfile --prefer-offline
- name: Build project - name: Validation
run: |
yarn oxlint .
yarn svelte-check
- name: Build for Production
run: yarn build run: yarn build
env: env:
NODE_ENV: production NODE_ENV: production
# Example deployment step - replace with your actual deployment strategy - name: Deploy Step
# Options:
# - Docker container registry
# - Cloud provider (AWS, GCP, Azure)
# - Traditional hosting (Vercel, Netlify, Cloudflare Pages)
# - SSH deployment to VPS
# Example: Docker image build and push
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - name: Log in to Container Registry
# uses: docker/login-action@v3
# with:
# registry: ${{ secrets.REGISTRY_URL }}
# username: ${{ secrets.REGISTRY_USERNAME }}
# password: ${{ secrets.REGISTRY_PASSWORD }}
# - name: Build and push Docker image
# uses: docker/build-push-action@v5
# with:
# context: .
# push: true
# tags: ${{ secrets.REGISTRY_URL }}/glyphdiff:latest
# cache-from: type=gha
# cache-to: type=gha,mode=max
# Example: SSH deployment to server
# - name: Deploy to server via SSH
# uses: appleboy/ssh-action@v1.0.3
# with:
# host: ${{ secrets.DEPLOY_HOST }}
# username: ${{ secrets.DEPLOY_USER }}
# key: ${{ secrets.DEPLOY_SSH_KEY }}
# script: |
# cd /path/to/app
# git pull origin main
# yarn install --frozen-lockfile
# yarn build
# pm2 restart glyphdiff
# Example: Deploy to Vercel
# - name: Deploy to Vercel
# uses: amondnet/vercel-action@v25
# with:
# vercel-token: ${{ secrets.VERCEL_TOKEN }}
# vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
# vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
# vercel-args: '--prod'
- name: Deployment placeholder
run: | run: |
echo "Deployment step not configured yet." echo "Deploying dist/ to ${{ github.event.inputs.environment || 'production' }}..."
echo "Uncomment and modify one of the deployment examples above." # EXAMPLE: rsync -avz dist/ user@your-vps:/var/www/html/
echo "Configure the necessary secrets in your Gitea instance:"
echo " - REGISTRY_URL, REGISTRY_USERNAME, REGISTRY_PASSWORD"
echo " - DEPLOY_HOST, DEPLOY_USER, DEPLOY_SSH_KEY"
echo " - VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID"
- name: Post-deployment health check
run: |
echo "Add health check here after deployment"
# curl -f https://your-app.com || exit 1
lint:
name: Lint Check
uses: ./.gitea/workflows/lint.yml
secrets: inherit
test:
name: Test Suite
uses: ./.gitea/workflows/test.yml
secrets: inherit
build:
name: Build Verification
uses: ./.gitea/workflows/build.yml
secrets: inherit

View File

@@ -31,11 +31,18 @@ jobs:
node-version: '20' node-version: '20'
cache: 'yarn' cache: 'yarn'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Persistent Yarn Cache
uses: actions/cache@v4
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies - name: Install dependencies
run: yarn install --frozen-lockfile run: yarn install --frozen-lockfile --prefer-offline
- name: Run oxlint
run: yarn oxlint .
- name: Check code formatting
run: yarn dprint check

View File

@@ -1,45 +1,31 @@
name: Test name: Test
on: on:
push: push:
branches: branches: [main, develop, "feature/*"]
- main
- develop
- feature/*
pull_request: pull_request:
branches: branches: [main, develop]
- main
- develop
workflow_dispatch: workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs: jobs:
type-check: test:
name: Type Check name: Svelte Checks
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - uses: actions/checkout@v4
uses: actions/checkout@v4 - uses: actions/setup-node@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with: with:
node-version: '20' node-version: '20'
cache: 'yarn' cache: 'yarn'
- name: Install dependencies - name: Install
run: yarn install --frozen-lockfile run: yarn install --frozen-lockfile --prefer-offline
- name: Run TypeScript type check - name: Type Check
run: yarn tsc --noEmit
- name: Run Svelte check
run: yarn svelte-check --threshold warning run: yarn svelte-check --threshold warning
- name: Lint
run: yarn oxlint .
# e2e-tests: # e2e-tests:
# name: E2E Tests (Playwright) # name: E2E Tests (Playwright)
# runs-on: ubuntu-latest # runs-on: ubuntu-latest