Skip to content

Implement build script and enhance README for Link features (#12) #8

Implement build script and enhance README for Link features (#12)

Implement build script and enhance README for Link features (#12) #8

Workflow file for this run

name: Build and Push Docker Image (Main Branch)
on:
push:
branches:
- main
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
BUILD_PLATFORMS: linux/amd64
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
- 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: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=main
type=sha,format=short
- name: Build and push Docker image
id: build
uses: docker/build-push-action@v6
with:
context: .
push: true
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: ${{ env.BUILD_PLATFORMS }}
- name: Test container health endpoint
shell: bash
run: |
set -euo pipefail
IMAGE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n 1)
docker run -d --name link-test -p 3000:3000 "$IMAGE_TAG"
trap 'docker rm -f link-test >/dev/null 2>&1 || true' EXIT
for attempt in $(seq 1 30); do
if curl -fsS http://127.0.0.1:3000/api/health >/dev/null; then
exit 0
fi
sleep 2
done
docker logs link-test
exit 1