63 lines
1.6 KiB
YAML
63 lines
1.6 KiB
YAML
name: Docker Image CI
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
branches: ['main']
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Install bun
|
|
uses: oven-sh/setup-bun@v2
|
|
- name: Install dependencies
|
|
run: bun install --include=dev
|
|
- name: Check formatting
|
|
run: bun run check
|
|
- name: Run tests
|
|
run: bun run test
|
|
deploy:
|
|
needs: test
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
attestations: write
|
|
id-token: write
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
if: github.ref == 'refs/heads/main'
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Login to Github Packages
|
|
uses: docker/login-action@v1
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Extract metadata for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
tags: |
|
|
# set latest tag for default branch
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
type=semver,pattern={{version}}
|
|
- name: Build and push
|
|
id: push
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
context: '.'
|
|
file: 'Dockerfile'
|
|
push: true
|
|
pull: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|