Skip to content

Frontend MVP

Frontend MVP #51

Workflow file for this run

name: CI
permissions:
contents: read
packages: write
on:
pull_request:
push:
branches: [main]
tags: ['*']
jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun setup
- run: bun check
build:
runs-on: ubuntu-latest
needs: checks
strategy:
matrix:
include:
- image: backend
context: .
dockerfile: ./backend/Dockerfile
target: ''
- image: web
context: .
dockerfile: ./web/Dockerfile
target: serve-web
- image: web-histoire
context: .
dockerfile: ./web/Dockerfile
target: serve-histoire
outputs:
backend-tags: ${{ steps.export.outputs.backend-tags }}
web-tags: ${{ steps.export.outputs.web-tags }}
web-histoire-tags: ${{ steps.export.outputs.web-histoire-tags }}
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/sync-${{ matrix.image }}
tags: |
type=ref,event=tag,priority=1000
type=ref,event=branch,priority=900
type=ref,event=pr,priority=800,prefix=pr-
flavor: |
latest=false
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
target: ${{ matrix.target }}
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
- name: Export metadata
id: export
run: |
if [[ "${{ matrix.image }}" == "backend" ]]; then
echo "backend-tags<<EOF" >> $GITHUB_OUTPUT
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
elif [[ "${{ matrix.image }}" == "web" ]]; then
echo "web-tags<<EOF" >> $GITHUB_OUTPUT
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
elif [[ "${{ matrix.image }}" == "web-histoire" ]]; then
echo "web-histoire-tags<<EOF" >> $GITHUB_OUTPUT
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
deploy:
runs-on: ubuntu-latest
needs: build
if: always() && needs.build.result == 'success'
steps:
- name: Print deployment info
run: |
echo "DEPLOYMENT SUMMARY"
echo "Commit SHA: ${{ github.sha }}"
echo ""
echo "BUILT IMAGES:"
echo ""
echo "backend:"
echo "${{ needs.build.outputs.backend-tags }}" | sed 's/^/ /'
echo ""
echo "web:"
echo "${{ needs.build.outputs.web-tags }}" | sed 's/^/ /'
echo ""
echo "web-histoire:"
echo "${{ needs.build.outputs.web-histoire-tags }}" | sed 's/^/ /'
- uses: actions/checkout@v4
- name: Extract tag name
id: tag
run: |
# Extract just the tag part (after the last colon)
TAG=$(echo "${{ needs.build.outputs.backend-tags }}" | sed 's/.*://')
echo "name=$TAG" >> $GITHUB_OUTPUT
- name: Deploy to test environment
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USERNAME }}
key: ${{ secrets.DEPLOY_KEY }}
script: ~/deploy-env.sh "${{ steps.tag.outputs.name }}" "${{ needs.build.outputs.backend-tags }}" "${{ needs.build.outputs.web-tags }}" "${{ needs.build.outputs.web-histoire-tags }}"