mirror of
https://github.com/traberph/short.git
synced 2026-11-22 22:55:12 +00:00
Uses the REGISTRY_USERNAME and REGISTRY_TOKEN secrets; the image is registry.traberph.de/traberph/short with the same tags as on GHCR and Docker Hub. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
91 lines
2.5 KiB
YAML
91 lines
2.5 KiB
YAML
name: Build and Push Docker Images
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- 'v*'
|
|
pull_request:
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
DOCKER_HUB_REGISTRY: docker.io
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
DOCKER_HUB_IMAGE_NAME: traberph/short
|
|
PRIVATE_REGISTRY: registry.traberph.de
|
|
PRIVATE_IMAGE_NAME: traberph/short
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: pnpm/action-setup@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 24
|
|
cache: pnpm
|
|
- run: pnpm install --frozen-lockfile
|
|
- run: pnpm typecheck
|
|
- run: pnpm test
|
|
- run: pnpm build
|
|
|
|
build-and-push:
|
|
needs: test
|
|
if: github.event_name == '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 GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.DOCKER_HUB_REGISTRY }}
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Log in to registry.traberph.de
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.PRIVATE_REGISTRY }}
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Extract metadata for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
${{ env.DOCKER_HUB_REGISTRY }}/${{ env.DOCKER_HUB_IMAGE_NAME }}
|
|
${{ env.PRIVATE_REGISTRY }}/${{ env.PRIVATE_IMAGE_NAME }}
|
|
tags: |
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}
|
|
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/heads/main') }}
|
|
|
|
- name: Build and push Docker images
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max |