prop/.forgejo/workflows/build.yaml
Graham McIntire b6caffea3e
feat(nav): show last-deployed timestamp
Docker final stage bakes BUILD_TIMESTAMP into /app/BUILD_TIMESTAMP via
build-arg (only consumed after mix compile, so earlier layer caching is
preserved). Application.build_timestamp/0 reads the file, falls back to
DEPLOY_TIMESTAMP env, then to compile time. Navbar renders a compact
"Deployed Xm ago" with the full UTC time in the tooltip.
2026-04-17 13:08:51 -05:00

49 lines
1.4 KiB
YAML

name: Build and Push
on:
push:
branches:
- main
env:
REGISTRY: git.mcintire.me
IMAGE_NAME: graham/prop
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-push:
name: Build and Push Docker Image
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: https://github.com/actions/checkout@v4
- name: Install Docker CLI
run: |
apt-get update && apt-get install -y docker.io
- name: Generate image tag
id: tag
run: |
TIMESTAMP=$(date +%s)
SHORT_SHA=$(git rev-parse --short=7 HEAD | cut -c1-7)
TAG="main-${TIMESTAMP}-${SHORT_SHA}"
echo "tag=${TAG}" >> $GITHUB_OUTPUT
- name: Log in to container registry
run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ secrets.REGISTRY_URL }} -u ${{ secrets.REGISTRY_USER }} --password-stdin
- name: Build and push Docker image
run: |
IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
TAG="${{ steps.tag.outputs.tag }}"
BUILD_TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
docker build \
--build-arg BUILD_TIMESTAMP="${BUILD_TIMESTAMP}" \
-t "${IMAGE}:${TAG}" -t "${IMAGE}:latest" .
docker push "${IMAGE}:${TAG}"
docker push "${IMAGE}:latest"