Skip to content

feat(timeline): PRs as first-class time-series metric on org + dev pa… #72

feat(timeline): PRs as first-class time-series metric on org + dev pa…

feat(timeline): PRs as first-class time-series metric on org + dev pa… #72

name: Build and Publish Docker Image
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
packages: write
concurrency:
group: docker-publish-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 20
cache: 'npm'
- run: npm ci
- run: npm test -- --ci
build-and-push:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- 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: Determine image tags
id: tags
run: |
SHA="${{ github.sha }}"
SHORT_SHA="${SHA:0:7}"
IMAGE="ghcr.io/${GITHUB_REPOSITORY,,}"
# Always tag with short commit SHA.
# workflow_dispatch can target any branch — this allows building
# feature branch images for testing before merge.
TAGS="${IMAGE}:${SHORT_SHA}"
# Only tag :latest on push to main (not on manual workflow_dispatch)
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
TAGS="${TAGS},${IMAGE}:latest"
fi
echo "tags=${TAGS}" >> "$GITHUB_OUTPUT"
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.tags.outputs.tags }}
build-args: |
COMMIT_SHA=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max