Skip to content

update default call formatters #526

update default call formatters

update default call formatters #526

Workflow file for this run

name: API Release
on:
push:
branches:
- main
paths:
- "apps/api/**"
release:
types: [published]
defaults:
run:
working-directory: apps/api
jobs:
test:
name: Test
runs-on: ubuntu-latest
services:
postgres:
image: ankane/pgvector:latest
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
steps:
- uses: erlef/setup-beam@v1
with:
otp-version: "26"
elixir-version: "1.16.1"
- uses: actions/checkout@v4
- name: 'Setup jq'
uses: dcarbone/install-jq-action@v2
- name: Cache deps
id: cache-deps
uses: actions/cache@v3
env:
cache-name: cache-elixir-deps
with:
path: apps/api/deps
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.cache-name }}-
- name: Cache compiled build
id: cache-build
uses: actions/cache@v3
env:
cache-name: cache-compiled-build
with:
path: apps/api/_build
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.cache-name }}-
${{ runner.os }}-mix-
- run: mix deps.get
- name: Compiles without warnings
run: mix compile
- run: mix test
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
if: ${{ github.event_name == 'push' }}
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.BUILDEL_API__FLY_API_TOKEN }}
if: ${{ github.event_name == 'push' }}
docker:
name: Docker
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Set up tags
id: set-tags
run: |
if [ "${{ github.event_name }}" == "push" ]; then
echo "tags=ghcr.io/${{ github.repository }}/api:${{ github.sha }},ghcr.io/${{ github.repository }}/api:alpha" >> $GITHUB_ENV
fi
if [ "${{ github.event_name }}" == "release" ]; then
is_latest=$(gh api repos/${{ github.repository }}/releases/latest | jq -r '.tag_name == "${{ github.event.release.tag_name }}"')
if [ "$is_latest" == "true" ]; then
echo "tags=ghcr.io/${{ github.repository }}/api:${{ github.sha }},ghcr.io/${{ github.repository }}/api:${{ github.event.release.tag_name }},ghcr.io/${{ github.repository }}/api:latest" >> $GITHUB_ENV
else
echo "tags=ghcr.io/${{ github.repository }}/api:${{ github.sha }},ghcr.io/${{ github.repository }}/api:${{ github.event.release.tag_name }}" >> $GITHUB_ENV
fi
fi
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: apps/api
tags: ${{ env.tags }}
push: ${{ github.event_name == 'push' || github.event_name == 'release' }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/api:alpha-cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/api:alpha-cache,mode=max