-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
228 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,227 @@ | ||
on: | ||
release: | ||
types: [published] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
ORGANIZATION: akdasa-studios | ||
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 | ||
platform: android | ||
# - config: | ||
# name: iOS | ||
# platform: ios | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
|
||
- name: Install tools | ||
run: | | ||
curl -fsSL https://ionic.io/get-appflow-cli | bash | ||
- name: Get Commit SHA | ||
id: commit_sha | ||
run: | | ||
echo $(git submodule status ./modules/apps/mobile) | ||
echo "::set-output name=sha::$(git submodule status ./modules/apps/mobile | awk '{print $1}' | cut -c 1-7)" | ||
- name: Build App | ||
run: | | ||
appflow build ${{ matrix.config.platform }} debug --commit=${{ steps.commit_sha.outputs.sha }} --app-id=${{ secrets.IONIC_APP_ID }} --token ${{ secrets.IONIC_TOKEN }} --environment="Staging" --apk-name=app.apk | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: app.apk | ||
path: app.apk | ||
|
||
# | ||
# 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" |