2
0
forked from jmug/cactoide

feat: add Github Action to build the image

This commit is contained in:
Levente Orban
2025-08-27 09:36:24 +02:00
parent 9feb3bf64d
commit 1091ffe959
6 changed files with 195 additions and 219 deletions

45
.github/workflows/build-and-push.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
name: Build and Push to GHCR
on:
push:
branches: [main]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/cactoide
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
- name: Output image info
if: github.event_name != 'pull_request'
run: |
echo "Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"

41
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,41 @@
name: Test and Build
on:
push:
branches: [main]
pull_request:
branches: ['**']
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run type checking
run: npm run check
- name: Run linting
run: npm run lint
- name: Build application
run: npm run build
- name: Test build output
run: |
if [ ! -d "build" ]; then
echo "Build directory not found!"
exit 1
fi
echo "Build successful! Build directory exists."