61 lines
1.7 KiB
YAML
61 lines
1.7 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://code.forgejo.org/actions/checkout@v4
|
|
|
|
- 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: Verify compilation
|
|
run: |
|
|
docker run --rm \
|
|
-v ${{ github.workspace }}:/app \
|
|
-w /app \
|
|
-e MIX_ENV=prod \
|
|
docker.io/hexpm/elixir:1.20.1-erlang-29.0.2-debian-trixie-20260518-slim \
|
|
sh -c '\
|
|
mix local.hex --force && \
|
|
mix local.rebar --force && \
|
|
mix deps.get --only prod && \
|
|
mix deps.compile && \
|
|
mix assets.setup && \
|
|
mix compile --warnings-as-errors'
|
|
|
|
- name: Build and Push via Kaniko
|
|
uses: graham/infra/.forgejo/actions/kaniko-build@main
|
|
with:
|
|
token: ${{ secrets.FORGEJO_TOKEN }}
|
|
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
tag: ${{ steps.tag.outputs.tag }}
|
|
|
|
- name: Tag as latest
|
|
uses: graham/infra/.forgejo/actions/kaniko-build@main
|
|
with:
|
|
token: ${{ secrets.FORGEJO_TOKEN }}
|
|
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
tag: latest
|
|
extra_args: ""
|