Skip to content

fix: More misc fixed, schema cleanup #295

fix: More misc fixed, schema cleanup

fix: More misc fixed, schema cleanup #295

Workflow file for this run

name: CI - API
on:
push:
branches: [ "main" ]
paths-ignore:
- '**/*.md'
- 'LICENSE'
- '**/.husky'
- 'sanity-cms/**'
- 'svelte-app/**'
concurrency:
group: api
cancel-in-progress: true
jobs:
test:
name: Test
environment: API
runs-on: ubuntu-latest
env:
ImageOS: ubuntu22
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: 1.14.0
otp-version: 25
rebar3-version: 3.16
- name: Check formatting
run: (cd ./elixir-api && mix format --check-formatted)
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: elixir-api/deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock')}}
restore-keys: ${{ runner.os }}-mix-
- name: Install Dependencies
run: (cd ./elixir-api && mix deps.get --only test)
- name: Run tests
run: |
cd ./elixir-api &&\
touch ./.env &&\
echo "export PORT=4444" >> .env &&\
echo "export SANITY_TOKEN=${{ secrets.SANITY_TOKEN }}" >> .env &&\
echo "export SANITY_PROJECT_ID=${{ secrets.SANITY_PROJECT_ID }}" >> .env &&\
echo "export API_TOKEN=${{ secrets.DEV_API_TOKEN }}" >> .env &&\
make test
build:
name: Build and Push
environment: API
needs: [ test ]
runs-on: ubuntu-latest
strategy:
matrix:
environment: [ dev, prod ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GCP Artifact Registry
uses: docker/login-action@v2
with:
registry: us-central1-docker.pkg.dev
username: _json_key
password: ${{ secrets.GCP_AR_PRIVATE_KEY }}
- name: Set API token
id: apitoken
run: |
if [[ "${{ matrix.environment }}" == "dev" ]]; then
echo "::set-output name=token::${{ secrets.DEV_API_TOKEN }}"
else
echo "::set-output name=token::${{ secrets.API_TOKEN }}"
fi
- name: Build and Push ${{ matrix.environment }} image
uses: docker/build-push-action@v2
with:
context: ./elixir-api
push: true
tags: |
us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/docker/hexerei-${{ matrix.environment }}:${{ github.sha }}
us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/docker/hexerei-${{ matrix.environment }}:latest
build-args: |
SANITY_TOKEN=${{ secrets.SANITY_TOKEN }}
SANITY_PROJECT_ID=${{ secrets.SANITY_PROJECT_ID }}
API_TOKEN=${{ steps.apitoken.outputs.token }}
ENV=${{ matrix.environment }}
GCLOUD_KEY=${{ secrets.GCLOUD_KEY }}
deploy:
name: Deploy
needs: [ build ]
runs-on: ubuntu-latest
strategy:
matrix:
environment: [ dev, prod ]
steps:
- name: Setup GCloud SDK
uses: google-github-actions/[email protected]
with:
service_account_key: ${{ secrets.GCP_CR_PRIVATE_KEY }}
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Deploy ${{ matrix.environment }} to Cloud Run
run: |
gcloud run deploy hexerei-${{ matrix.environment }} --image us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/docker/hexerei-${{ matrix.environment }}:latest --region us-central1 --platform managed