# What - Bumps backend dependencies, including Spring Boot to v4.1.0 # Why - Service hygiene. Reviewed-on: #2
127 lines
3.7 KiB
YAML
127 lines
3.7 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 Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Extract metadata for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: rmcampos/tasknote-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=rmcampos/tasknote-app:buildcache
|
|
cache-to: type=registry,ref=rmcampos/tasknote-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\"}"
|