neiam
/feedpug
feedpub
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
ci: add GitHub Actions workflow (test + multi-registry image push)
12d5381 · gmorell · 2026-06-27 15:07
Files changed
added
.github/workflows/ci.yml
+120
−0
@@ -0,0 +1,120 @@
| 1 | +name: ci | |
| 2 | + | |
| 3 | +on: | |
| 4 | + push: | |
| 5 | + branches: [master] | |
| 6 | + tags: ["v*"] | |
| 7 | + pull_request: | |
| 8 | + | |
| 9 | +jobs: | |
| 10 | + test: | |
| 11 | + # Self-hosted ARC runners (same as ../angler). Swap for `ubuntu-latest` | |
| 12 | + # if you'd rather use GitHub-hosted runners. The Postgres service container | |
| 13 | + # requires the runner to support service containers (Docker/dind). | |
| 14 | + runs-on: arc-runner-set | |
| 15 | + env: | |
| 16 | + MIX_ENV: test | |
| 17 | + # Cap the test DB pool below the Postgres service's default | |
| 18 | + # max_connections (100); big CI runners otherwise scale pool to cores×2 | |
| 19 | + # and exhaust connections. | |
| 20 | + POOL_SIZE: "40" | |
| 21 | + services: | |
| 22 | + postgres: | |
| 23 | + image: docker.io/postgres:16-alpine | |
| 24 | + env: | |
| 25 | + POSTGRES_USER: postgres | |
| 26 | + POSTGRES_PASSWORD: postgres | |
| 27 | + ports: | |
| 28 | + - 5432:5432 | |
| 29 | + options: >- | |
| 30 | + --health-cmd "pg_isready -U postgres" | |
| 31 | + --health-interval 5s | |
| 32 | + --health-timeout 3s | |
| 33 | + --health-retries 5 | |
| 34 | + steps: | |
| 35 | + - uses: actions/checkout@v4 | |
| 36 | + | |
| 37 | + # ARC's default runner image is bare; install the toolchain needed to | |
| 38 | + # compile native deps. | |
| 39 | + - run: sudo apt-get update && sudo apt-get install -y --no-install-recommends make build-essential | |
| 40 | + | |
| 41 | + - uses: erlef/setup-beam@v1 | |
| 42 | + with: | |
| 43 | + # Match the build image in the Dockerfile. | |
| 44 | + elixir-version: "1.20.1" | |
| 45 | + otp-version: "28.4.1" | |
| 46 | + | |
| 47 | + - uses: actions/cache@v4 | |
| 48 | + with: | |
| 49 | + path: | | |
| 50 | + deps | |
| 51 | + _build | |
| 52 | + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} | |
| 53 | + restore-keys: ${{ runner.os }}-mix- | |
| 54 | + | |
| 55 | + - run: mix deps.get | |
| 56 | + | |
| 57 | + # `mix precommit` = compile --warnings-as-errors, deps.unlock --unused, | |
| 58 | + # format, test (which creates + migrates the test DB). | |
| 59 | + - run: mix precommit | |
| 60 | + | |
| 61 | + image: | |
| 62 | + needs: test | |
| 63 | + runs-on: arc-runner-set | |
| 64 | + permissions: | |
| 65 | + contents: read | |
| 66 | + packages: write | |
| 67 | + steps: | |
| 68 | + - uses: actions/checkout@v4 | |
| 69 | + - uses: docker/setup-buildx-action@v3 | |
| 70 | + | |
| 71 | + # GHCR uses the built-in token. Docker Hub and Quay creds come from | |
| 72 | + # org-wide secrets (DOCKERHUB_USER/DOCKERHUB_TOKEN, QUAY_USERNAME/QUAY_TOKEN). | |
| 73 | + - name: Log in to GHCR | |
| 74 | + if: github.event_name != 'pull_request' | |
| 75 | + uses: docker/login-action@v3 | |
| 76 | + with: | |
| 77 | + registry: ghcr.io | |
| 78 | + username: ${{ github.actor }} | |
| 79 | + password: ${{ secrets.GITHUB_TOKEN }} | |
| 80 | + | |
| 81 | + - name: Log in to Docker Hub | |
| 82 | + if: github.event_name != 'pull_request' | |
| 83 | + uses: docker/login-action@v3 | |
| 84 | + with: | |
| 85 | + registry: docker.io | |
| 86 | + username: ${{ secrets.DOCKERHUB_USER }} | |
| 87 | + password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| 88 | + | |
| 89 | + - name: Log in to Quay | |
| 90 | + if: github.event_name != 'pull_request' | |
| 91 | + uses: docker/login-action@v3 | |
| 92 | + with: | |
| 93 | + registry: quay.io | |
| 94 | + username: ${{ secrets.QUAY_USERNAME }} | |
| 95 | + password: ${{ secrets.QUAY_TOKEN }} | |
| 96 | + | |
| 97 | + - id: meta | |
| 98 | + uses: docker/metadata-action@v5 | |
| 99 | + with: | |
| 100 | + images: | | |
| 101 | + ghcr.io/${{ github.repository }} | |
| 102 | + docker.io/neiam/feedpug | |
| 103 | + quay.io/neiam/feedpug | |
| 104 | + tags: | | |
| 105 | + type=ref,event=branch | |
| 106 | + type=ref,event=pr | |
| 107 | + type=semver,pattern={{version}} | |
| 108 | + type=semver,pattern={{major}}.{{minor}} | |
| 109 | + type=sha | |
| 110 | + type=raw,value=latest,enable={{is_default_branch}} | |
| 111 | + | |
| 112 | + - uses: docker/build-push-action@v6 | |
| 113 | + with: | |
| 114 | + context: . | |
| 115 | + platforms: linux/amd64 | |
| 116 | + push: ${{ github.event_name != 'pull_request' }} | |
| 117 | + tags: ${{ steps.meta.outputs.tags }} | |
| 118 | + labels: ${{ steps.meta.outputs.labels }} | |
| 119 | + cache-from: type=gha | |
| 120 | + cache-to: type=gha,mode=max |
Parents: b3ed374