Skip to content

fix: point app GitHub link to FirstSun repository #30

fix: point app GitHub link to FirstSun repository

fix: point app GitHub link to FirstSun repository #30

name: Build and Push Docker Image
on:
push:
paths:
- 'Dockerfile'
- '.dockerignore'
- 'package.json'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- 'cli/**'
- 'server/**'
- 'dashboard/**'
- '.github/workflows/build-and-push-image.yml'
branches:
- main
- master
workflow_dispatch:
jobs:
build-and-push:
name: Build and Push Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm build
- name: Test
run: pnpm test
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/${{ github.repository_owner }}/code-insights
tags: |
type=raw,value=latest
type=sha,format=short
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Remove superseded image versions so multi-arch builds don't fill the
# org's shared package/artifact storage quota. Manifest-list aware, so the
# child manifests of kept tags are preserved (naive "delete untagged" would
# break the current multi-arch image).
cleanup:
name: Cleanup old image versions
needs: build-and-push
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Delete untagged and superseded versions
uses: dataaxiom/ghcr-cleanup-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
package: code-insights
# Keep only the newest tagged build (carries `latest` + its `sha-*`);
# bump this if you want rollback headroom for older commits.
keep-n-tagged: 1
delete-untagged: true
delete-partial-images: true
delete-ghost-images: true
validate: true