name: ci
on:
push:
branches: [master]
tags: ["v*"]
pull_request:
jobs:
test:
# Self-hosted ARC runners (same as ../angler). Swap for `ubuntu-latest`
# if you'd rather use GitHub-hosted runners. The Postgres service container
# requires the runner to support service containers (Docker/dind).
runs-on: arc-runner-set
env:
MIX_ENV: test
# Under forgejo-runner/act the job runs in a container, so the postgres
# service is reached by its service name, not localhost.
POSTGRES_HOST: postgres
# Cap the test DB pool below the Postgres service's default
# max_connections (100); big CI runners otherwise scale pool to cores×2
# and exhaust connections.
POOL_SIZE: "40"
services:
postgres:
image: docker.io/postgres:16-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 5s
--health-timeout 3s
--health-retries 5
steps:
- uses: actions/checkout@v4
# ARC's default runner image is bare; install the toolchain needed to
# compile native deps.
- run: sudo apt-get update && sudo apt-get install -y --no-install-recommends make build-essential
# Forge fork of erlef/setup-beam: defaults ImageOS to ubuntu-24.04,
# since forgejo/act injects an unmappable ImageOS from the runs-on label.
- uses: https://gg.neiam.co/neiam/action-setup-beam@v1
with:
# Match the build image in the Dockerfile.
elixir-version: "1.20.4"
otp-version: "28.5.0.8"
- uses: actions/cache@v4
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- run: mix deps.get
# `mix precommit` = compile --warnings-as-errors, deps.unlock --unused,
# format, test (which creates + migrates the test DB).
- run: mix precommit
image:
needs: test
runs-on: arc-runner-set
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
# An unset CI_REGISTRY resolves to the empty string, and
# login-action then silently defaults to docker.io while
# metadata-action builds a nonsense "/owner/repo" reference. Say
# what is missing instead.
- name: Check the registry variable is set
env:
CI_REGISTRY: ${{ vars.CI_REGISTRY }}
run: |
set -euo pipefail
if [ -z "${CI_REGISTRY:-}" ]; then
echo "CI_REGISTRY is not set for this repository." >&2
echo "Set it as an organisation-level Actions variable (the" >&2
echo "registry hostname), the same one gitgud builds against." >&2
exit 1
fi
echo "pushing to $CI_REGISTRY"
# GHCR uses the built-in token. Docker Hub and Quay creds come from
# org-wide secrets (DOCKERHUB_USER/DOCKERHUB_TOKEN, QUAY_USERNAME/QUAY_TOKEN).
# The forge's own registry: no stored credential, the per-job token
# is authorized to push this repository's own image path.
- name: Log in to the forge registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ vars.CI_REGISTRY }}
username: ci
password: ${{ github.token }}
- name: Log in to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ vars.GHCR_USER || github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to Quay
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
- id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ vars.CI_REGISTRY }}/${{ github.repository }}
ghcr.io/${{ github.repository }}
docker.io/neiam/feedpug
quay.io/neiam/feedpug
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
neiam
/feedpug
feedpub
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
5.0 KiB · text
History
3488b6a