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
on: | |
push: | |
# branches: | |
# - main | |
env: | |
REGISTRY: ghcr.io | |
ORGANIZATION: akdasa-studios | |
VERSION: v0.1.0 | |
# VERSION: ${{ github.event.release.tag_name }} | |
jobs: | |
# | |
# Stage 1: Build backend and staging mobile apps | |
# | |
build-backend: | |
name: Build / ${{ matrix.config.name }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
matrix: | |
include: | |
- config: | |
name: Gateway | |
service: gateway | |
context: ./modules/services/gateway | |
- config: | |
name: Database | |
service: database | |
context: ./modules/services/database/modules/database | |
- config: | |
name: Database Boostrtap | |
service: database-bootstrap | |
context: ./modules/services/database/modules/bootstrap | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Setup Docker | |
uses: docker/setup-buildx-action@v2 | |
- name: Log into registry ${{ env.REGISTRY }} | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Image | |
uses: docker/build-push-action@v6 | |
with: | |
context: ${{ matrix.config.context }} | |
load: true | |
tags: | | |
${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/lectorium-${{ matrix.config.service }}:${{ env.VERSION }}-dev | |
- name: Push Image | |
run: | | |
docker push ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/lectorium-${{ matrix.config.service }}:${{ env.VERSION }}-dev | |
build-mobile-staging: | |
name: Build / ${{ matrix.config.name }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
matrix: | |
include: | |
- config: | |
name: Android | |
- config: | |
name: iOS | |
- config: | |
name: Web | |
steps: | |
- name: Build App | |
run: | | |
echo "Building ${{ matrix.config.name }} app" | |
# | |
# Stage 2: Deploy backend to staging | |
# | |
deploy-backend-staging: | |
name: Deploy / Staging | |
runs-on: ubuntu-latest | |
environment: Staging | |
needs: build-backend | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Log into registry ${{ env.REGISTRY }} | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Promote Images | |
run: | | |
for service in gateway database database-bootstrap; do | |
docker pull ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/lectorium-$service:${{ env.VERSION }}-dev | |
docker tag ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/lectorium-$service:${{ env.VERSION }}-dev ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/lectorium-$service:${{ env.VERSION }}-rc | |
docker push ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/lectorium-$service:${{ env.VERSION }}-rc | |
done | |
# | |
# Stage 3: Run E2E tests | |
# | |
tests-e2e: | |
name: E2E Tests | |
runs-on: ubuntu-latest | |
needs: [deploy-backend-staging, build-mobile-staging] | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Run E2E Tests | |
run: | | |
echo "Running E2E tests" | |
# | |
# Stage 4: Build production mobile apps and deploy to production | |
# | |
build-mobile-production: | |
name: Build / ${{ matrix.config.name }} | |
runs-on: ubuntu-latest | |
needs: [tests-e2e] | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
matrix: | |
include: | |
- config: | |
name: Android | |
- config: | |
name: iOS | |
- config: | |
name: Web | |
steps: | |
- name: Build App | |
run: | | |
echo "Building ${{ matrix.config.name }} app" | |
deploy-backend-production: | |
name: Deploy / Production | |
runs-on: ubuntu-latest | |
environment: Production | |
needs: [tests-e2e] | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Log into registry ${{ env.REGISTRY }} | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Promote Images | |
run: | | |
for service in gateway database database-bootstrap; do | |
docker pull ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/lectorium-$service:${{ env.VERSION }}-rc | |
docker tag ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/lectorium-$service:${{ env.VERSION }}-rc ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/lectorium-$service:${{ env.VERSION }} | |
docker tag ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/lectorium-$service:${{ env.VERSION }}-rc ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/lectorium-$service:latest | |
docker push ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/lectorium-$service:${{ env.VERSION }} | |
docker push ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/lectorium-$service:latest | |
done | |
# | |
# Stage 5: Publish mobile apps | |
# | |
publish-mobile: | |
name: Publish / ${{ matrix.config.name }} | |
runs-on: ubuntu-latest | |
needs: [deploy-backend-production, build-mobile-production] | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
matrix: | |
include: | |
- config: | |
name: Android | |
- config: | |
name: iOS | |
steps: | |
- name: Publish App | |
run: | | |
echo "Publishing ${{ matrix.config.name }} app" |