159 lines
5.8 KiB
YAML
159 lines
5.8 KiB
YAML
name: Frontend Admin - EAS Build
|
|
|
|
on:
|
|
push:
|
|
branches: [main, pre-prod]
|
|
paths:
|
|
- "mobile/**"
|
|
pull_request:
|
|
branches: [main, pre-prod]
|
|
paths:
|
|
- "mobile/**"
|
|
|
|
jobs:
|
|
typecheck:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: mobile/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
working-directory: mobile
|
|
run: npm ci
|
|
|
|
- name: Typecheck
|
|
working-directory: mobile
|
|
run: npx tsc --noEmit
|
|
|
|
build-apk:
|
|
needs: typecheck
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: mobile/package-lock.json
|
|
|
|
- name: Setup Java
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: temurin
|
|
java-version: 17
|
|
|
|
- name: Setup Android SDK
|
|
uses: android-actions/setup-android@v3
|
|
|
|
- name: Install EAS CLI
|
|
run: npm install -g eas-cli
|
|
|
|
- name: Install dependencies
|
|
working-directory: mobile
|
|
run: npm ci
|
|
|
|
- name: Inject EAS project ID
|
|
working-directory: mobile
|
|
run: |
|
|
jq '.expo.extra.eas.projectId = "${{ secrets.EXPO_PROJECT_ID_CLIENT }}"' app.json > app.tmp.json
|
|
mv app.tmp.json app.json
|
|
|
|
- name: Determine build profile & env
|
|
id: config
|
|
run: |
|
|
if [ "${{ github.ref_name }}" = "main" ] || [ "${{ github.base_ref }}" = "main" ]; then
|
|
echo "profile=production" >> $GITHUB_OUTPUT
|
|
echo "channel=production" >> $GITHUB_OUTPUT
|
|
echo "api_url=https://mln-uber.club" >> $GITHUB_OUTPUT
|
|
echo "apk_name=admin-panel-production-$(date +%Y%m%d-%H%M).apk" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "profile=pre-prod" >> $GITHUB_OUTPUT
|
|
echo "channel=pre-prod" >> $GITHUB_OUTPUT
|
|
echo "api_url=https://5.181.0.112.nip.io" >> $GITHUB_OUTPUT
|
|
echo "apk_name=admin-panel-preview-$(date +%Y%m%d-%H%M).apk" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Build APK (local)
|
|
working-directory: mobile
|
|
env:
|
|
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
|
|
EXPO_PUBLIC_API_URL: ${{ steps.config.outputs.api_url }}
|
|
EAS_BUILD_NO_EXPO_GO_WARNING: true
|
|
run: eas build --platform android --profile ${{ steps.config.outputs.profile }} --local --non-interactive
|
|
|
|
- name: Rename APK
|
|
working-directory: mobile
|
|
run: mv *.apk ${{ steps.config.outputs.apk_name }}
|
|
|
|
- name: Upload APK to RustFS
|
|
working-directory: mobile
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.RUSTFS_ACCESS_KEY }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.RUSTFS_SECRET_KEY }}
|
|
AWS_DEFAULT_REGION: us-east-1
|
|
run: |
|
|
aws s3 cp ${{ steps.config.outputs.apk_name }} \
|
|
s3://apk-builds/${{ steps.config.outputs.profile }}/${{ steps.config.outputs.apk_name }} \
|
|
--endpoint-url https://rustfs.uber-stup.club \
|
|
--no-verify-ssl
|
|
|
|
ota-update:
|
|
needs: build-apk
|
|
runs-on: ubuntu-latest
|
|
# Ne publie pas sur les PR, seulement sur les pushs
|
|
if: github.event_name == 'push'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: mobile/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
working-directory: mobile
|
|
run: npm ci
|
|
|
|
- name: Install EAS CLI
|
|
run: npm install -g eas-cli
|
|
|
|
- name: Determine channel & env
|
|
id: config
|
|
run: |
|
|
if [ "${{ github.ref_name }}" = "main" ]; then
|
|
echo "channel=production" >> $GITHUB_OUTPUT
|
|
echo "api_url=https://mln-uber.club" >> $GITHUB_OUTPUT
|
|
echo "message=Production update $(date +%Y%m%d-%H%M)" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "channel=pre-prod" >> $GITHUB_OUTPUT
|
|
echo "api_url=https://5.181.0.112.nip.io" >> $GITHUB_OUTPUT
|
|
echo "message=Preview update $(date +%Y%m%d-%H%M)" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Publish OTA update to Xavia
|
|
working-directory: mobile
|
|
env:
|
|
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
|
|
EXPO_PUBLIC_API_URL: ${{ steps.config.outputs.api_url }}
|
|
XAVIA_SERVER_URL: https://ota.uber-stup.club
|
|
run: |
|
|
npx expo export --platform android
|
|
curl -X POST "$XAVIA_SERVER_URL/api/updates" \
|
|
-H "Authorization: Bearer ${{ secrets.XAVIA_API_KEY }}" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"channel": "${{ steps.config.outputs.channel }}",
|
|
"message": "${{ steps.config.outputs.message }}",
|
|
"platform": "android"
|
|
}'
|