Files
tasknote/.github/workflows/ci-pr-frontend.yml
T
rmcampos daed3c2909
Pull Request CI-Backend / Checks (pull_request) Successful in 6m26s
Pull Request CI-Backend / Build & Push (pull_request) Successful in 8m14s
Pull Request CI-Frontend / Checks (pull_request) Successful in 6m5s
staging/deploy PR #2 staging ready
Pull Request CI-Frontend / Build & Push (pull_request) Successful in 3m5s
fix: buildx plugin and cache debug
2026-06-15 14:27:08 -03:00

128 lines
3.9 KiB
YAML

name: Pull Request CI-Frontend
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]
branches:
- 'main'
paths:
- 'client/**/*.html'
- 'client/**/*.png'
- 'client/**/*.json'
- 'client/**/*.txt'
- 'client/**/*.ts'
- 'client/**/*.tsx'
- 'client/**/*.js'
- 'client/Dockerfile'
- 'client/Caddyfile'
- '.github/workflows/ci-pr-frontend.yml'
jobs:
run-checks:
name: Checks
runs-on: easynode-debian
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/client/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Debug cache env
run: |
echo "CACHE_URL=${ACTIONS_CACHE_URL}"
echo "RUNTIME_URL=${ACTIONS_RUNTIME_URL}"
curl -s -w "\nHTTP: %{http_code}\n" \
-H "Authorization: Bearer ${ACTIONS_RUNTIME_TOKEN}" \
"${ACTIONS_CACHE_URL}_apis/artifactcache/cache?keys=test&version=test"
- name: Install dependencies
run: npm install
working-directory: ./client
- name: Run lint
run: npm run lint
working-directory: ./client
- name: Run build
run: npm run build
working-directory: ./client
- name: Run tests
run: npm run test:no-watch
working-directory: ./client
build-and-push:
name: Build & Push
runs-on: easynode-debian
needs: ["run-checks"]
permissions:
contents: write
packages: write
deployments: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
run: docker buildx inspect --bootstrap
- name: Log in to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: lightroasted.vps-kinghost.net
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: lightroasted.vps-kinghost.net/${{ github.repository }}/app
tags: |
type=raw,value=candidate
type=raw,value=pr-${{ github.event.pull_request.number }}
- name: Generate version tag
id: version
run: |
DATE=$(date +'%Y.%m.%d')
TAG="app-v${DATE}.${{ github.run_number }}"
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "Generated tag: ${TAG}"
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./client
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=lightroasted.vps-kinghost.net/${{ github.repository }}/app:buildcache
cache-to: type=registry,ref=lightroasted.vps-kinghost.net/${{ github.repository }}/app:buildcache,mode=max
build-args: |
VITE_BUILD=${{ steps.version.outputs.tag }}
- name: Create Gitea deployment for staging
if: ${{ github.event_name == 'pull_request' }}
run: |
curl -s -X POST \
-H "Authorization: token ${{ secrets.REGISTRY_TOKEN }}" \
-H "Content-Type: application/json" \
"https://lightroasted.vps-kinghost.net/api/v1/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }}" \
-d "{\"context\": \"staging/deploy\", \"state\": \"success\", \"description\": \"PR #${{ github.event.pull_request.number }} staging ready\", \"target_url\": \"https://tasknote-stg.darkroasted.vps-kinghost.net\"}"