Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(github-workflows): add ci for pr build check and release #110

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy-documentation.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: deploy-documentation

on: [push, pull_request, workflow_dispatch]
on: [push, workflow_dispatch]

permissions:
contents: write
Expand Down
117 changes: 117 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: PR Check Pipeline

on:
pull_request:
branches: [ master, dev, cma/feat-ci-build-docker ]

jobs:
build:
runs-on: ubuntu-latest
environment: docker-build
outputs:
has_apk: ${{ steps.check_pr.outputs.is_master }}

steps:
- uses: actions/checkout@v4

- name: Check if PR targets master or test branch
id: check_pr
run: |
echo "is_master=${{ github.base_ref == 'master' || github.base_ref == 'cma/feat-ci-build-docker' }}" >> $GITHUB_OUTPUT

- name: Create env files
run: |
# Create mobile env file
cat << EOF > client_mobile/.env.mobile
VITE_PORT=${{ secrets.VITE_PORT }}
VITE_ENDPOINT=${{ secrets.VITE_ENDPOINT }}
VITE_GOOGLE_CLIENT_ID=${{ secrets.VITE_GOOGLE_CLIENT_ID }}
VITE_GOOGLE_CLIENT_SECRET=${{ secrets.VITE_GOOGLE_CLIENT_SECRET }}
VITE_MICROSOFT_CLIENT_ID=${{ secrets.VITE_MICROSOFT_CLIENT_ID }}
VITE_LINKEDIN_CLIENT_ID=${{ secrets.VITE_LINKEDIN_CLIENT_ID }}
VITE_LINKEDIN_CLIENT_SECRET=${{ secrets.VITE_LINKEDIN_CLIENT_SECRET }}
VITE_SPOTIFY_CLIENT_ID=${{ secrets.VITE_SPOTIFY_CLIENT_ID }}
VITE_SPOTIFY_CLIENT_SECRET=${{ secrets.VITE_SPOTIFY_CLIENT_SECRET }}
API_URL=${{ secrets.API_URL }}
WEB_CLIENT_URL=${{ secrets.WEB_CLIENT_URL }}
MOBILE_CLIENT_URL=${{ secrets.MOBILE_CLIENT_URL }}
GITHUB_CLIENT_ID=${{ secrets.GH_CLIENT_ID }}
GITHUB_CLIENT_SECRET=${{ secrets.GH_CLIENT_SECRET }}
EOF

# Create web env file
cat << EOF > client_web/.env.local
VITE_PORT=${{ secrets.VITE_PORT }}
VITE_ENDPOINT=${{ secrets.VITE_ENDPOINT }}
VITE_GOOGLE_CLIENT_ID=${{ secrets.VITE_GOOGLE_CLIENT_ID }}
VITE_GOOGLE_CLIENT_SECRET=${{ secrets.VITE_GOOGLE_CLIENT_SECRET }}
VITE_MICROSOFT_CLIENT_ID=${{ secrets.VITE_MICROSOFT_CLIENT_ID }}
VITE_LINKEDIN_CLIENT_ID=${{ secrets.VITE_LINKEDIN_CLIENT_ID }}
VITE_LINKEDIN_CLIENT_SECRET=${{ secrets.VITE_LINKEDIN_CLIENT_SECRET }}
VITE_SPOTIFY_CLIENT_ID=${{ secrets.VITE_SPOTIFY_CLIENT_ID }}
VITE_SPOTIFY_CLIENT_SECRET=${{ secrets.VITE_SPOTIFY_CLIENT_SECRET }}
API_URL=${{ secrets.API_URL }}
WEB_CLIENT_URL=${{ secrets.WEB_CLIENT_URL }}
MOBILE_CLIENT_URL=${{ secrets.MOBILE_CLIENT_URL }}
GITHUB_CLIENT_ID=${{ secrets.GH_CLIENT_ID }}
GITHUB_CLIENT_SECRET=${{ secrets.GH_CLIENT_SECRET }}
EOF

# Create root env file if needed
cat << EOF > .env
VITE_PORT=${{ secrets.VITE_PORT }}
EOF

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker images
run: |
docker compose up --build -d

- name: Extract APK
if: github.base_ref == 'master'
run: |
mkdir -p artifacts
docker cp $(docker ps -qf "name=area-client-web"):/usr/share/nginx/html/mobile_builds/client.apk ./artifacts/

- name: Upload APK artifact
if: github.base_ref == 'master'
uses: actions/upload-artifact@v4
with:
name: mobile-apk
path: artifacts/client.apk
retention-days: 1

release:
needs: build
runs-on: ubuntu-latest
environment: docker-build

steps:
- name: Download APK from build
uses: actions/download-artifact@v4
with:
name: mobile-apk
path: artifacts

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.run_number }}
release_name: Release v${{ github.run_number }}
draft: false
prerelease: false

- name: Upload Release APK
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/client.apk
asset_name: area-mobile-v${{ github.run_number }}.apk
asset_content_type: application/vnd.android.package-archive
1 change: 1 addition & 0 deletions client_mobile/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ migrate_working_dir/
.pub-cache/
.pub/
/build/
client_mobile/pubspec.lock

# Symbolication related
app.*.symbols
Expand Down
2 changes: 1 addition & 1 deletion client_mobile/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ARG GITHUB_CLIENT_SECRET
COPY . .

RUN flutter pub get
RUN flutter build apk --release
RUN flutter build apk

RUN mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/client.apk
RUN chmod -R 755 build/app/outputs/flutter-apk/
2 changes: 1 addition & 1 deletion client_mobile/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pluginManagement {
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
id "org.jetbrains.kotlin.android" version "1.9.22" apply false
}

include ":app"
Loading
Loading