Merge pull request #374 from Flo0807/renovate/daisyui-5.x #650
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
test: | |
name: Test app | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:17-alpine@sha256:7062a2109c4b51f3c792c7ea01e83ed12ef9a980886e3b3d380a7d2e5f6ce3f5 | |
env: | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
-p 5432:5432 | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: erlef/setup-beam@5304e04ea2b355f03681464e683d92e3b2f18451 # v1.18.2 | |
id: beam | |
with: | |
version-file: .tool-versions | |
version-type: strict | |
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 | |
with: | |
cache: 'npm' | |
cache-dependency-path: './assets/package-lock.json' | |
node-version: 20 | |
- name: Install npm dependencies | |
run: npm ci | |
working-directory: ./assets | |
- name: Restore the deps and _build cache | |
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 | |
id: restore-cache | |
env: | |
OTP_VERSION: ${{ steps.beam.outputs.otp-version }} | |
ELIXIR_VERSION: ${{ steps.beam.outputs.elixir-version }} | |
MIX_LOCK_HASH: ${{ hashFiles('**/mix.lock') }} | |
with: | |
path: | | |
deps | |
_build | |
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-mixlockhash-${{ env.MIX_LOCK_HASH }} | |
- name: Install mix dependencies | |
if: steps.restore-cache.outputs.cache-hit != 'true' | |
run: mix deps.get | |
- name: Compile dependencies | |
if: steps.restore-cache.outputs.cache-hit != 'true' | |
run: mix deps.compile | |
- name: Compile | |
run: mix compile --warnings-as-errors --force | |
- name: Check Formatting (Elixir) | |
run: mix format --check-formatted | |
- name: Check Formatting (JS) | |
run: npm run lint:standard | |
working-directory: ./assets | |
- name: Gettext | |
run: mix gettext.extract --check-up-to-date | |
- name: Credo | |
run: mix credo | |
- name: Run Tests | |
run: mix test | |
build-push: | |
name: Build and push image to ghcr | |
runs-on: ubuntu-latest | |
needs: test | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Lowercase image name | |
run: echo "IMAGE_NAME=$(echo "$IMAGE_NAME" | awk '{print tolower($0)}')" >> $GITHUB_ENV | |
- name: Log in to the container registry | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push | |
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0 | |
with: | |
context: . | |
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }} | |
build-args: FLY_IO_RELEASE="false" | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache | |
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max | |
deploy: | |
name: Deploy app to fly.io | |
runs-on: ubuntu-latest | |
needs: build-push | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: superfly/flyctl-actions/setup-flyctl@master | |
- run: flyctl deploy --remote-only |