From 89713db9b53cd7e218ccf9ad5d91533a11a7a8b3 Mon Sep 17 00:00:00 2001 From: hyochan Date: Wed, 14 Aug 2024 10:56:21 +0900 Subject: [PATCH] ci: setup web hosting --- .firebaserc | 19 +++++- .github/workflows/deploy-pr.yml | 57 ++++++++++++++++++ .github/workflows/deploy.yml | 39 +++++++++++-- .gitignore | 6 +- bun.lockb | Bin 960037 -> 960037 bytes dist/apple-app-site-association | 11 ++++ dist/index.html | 37 ++++++++++++ firebase.json | 100 ++++++++++++++++++++++++++++++++ package.json | 3 +- 9 files changed, 261 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/deploy-pr.yml create mode 100644 dist/apple-app-site-association create mode 100644 dist/index.html create mode 100644 firebase.json diff --git a/.firebaserc b/.firebaserc index a4378cc..58eed9d 100644 --- a/.firebaserc +++ b/.firebaserc @@ -1,5 +1,18 @@ { "projects": { - "default": "" - } -} + "default": "crossplatformkorea2024" + }, + "targets": { + "crossplatformkorea2024": { + "hosting": { + "staging": [ + "cpk-staging" + ], + "app": [ + "crossplatformkorea2024" + ] + } + } + }, + "etags": {} +} \ No newline at end of file diff --git a/.github/workflows/deploy-pr.yml b/.github/workflows/deploy-pr.yml new file mode 100644 index 0000000..c89db65 --- /dev/null +++ b/.github/workflows/deploy-pr.yml @@ -0,0 +1,57 @@ +name: Deploy Web on PR +'on': pull_request + +permissions: + checks: write + contents: read + pull-requests: write + +jobs: + build_and_deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20.x + - uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + # - uses: expo/expo-github-action@v8 + # with: + # expo-version: latest + # eas-version: latest + # token: ${{ secrets.EXPO_TOKEN }} + + - name: Install modules + run: bun install --immutable + + - name: Build web + run: bun build:web + env: + supabaseUrl: ${{ secrets.supabaseUrl }} + supabaseAnonKey: ${{ secrets.supabaseAnonKey }} + googleClientIdWeb: ${{ secrets.googleClientIdWeb }} + expoProjectId: ${{ secrets.expoProjectId }} + + # Meta tags are not updatable from Expo SDK 49 so add below step + - name: Inject Meta Tags + run: | + sed -i '/<\/head>/i \ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n' ./dist/index.html + + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: '${{ secrets.GITHUB_TOKEN }}' + firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_CROSSPLATFORMKOREA2024 }}' + channelId: live + projectId: crossplatformkorea2024 + target: cpk-staging diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d0c0a63..25dbcfb 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,15 +8,18 @@ jobs: build_and_deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20.x - uses: oven-sh/setup-bun@v1 with: bun-version: latest - - uses: expo/expo-github-action@v8 - with: - expo-version: latest - eas-version: latest - token: ${{ secrets.EXPO_TOKEN }} + # - uses: expo/expo-github-action@v8 + # with: + # expo-version: latest + # eas-version: latest + # token: ${{ secrets.EXPO_TOKEN }} - name: Install modules run: bun install --immutable @@ -24,4 +27,28 @@ jobs: - name: Build web run: bun build:web env: + supabaseUrl: ${{ secrets.supabaseUrl }} + supabaseAnonKey: ${{ secrets.supabaseAnonKey }} + googleClientIdWeb: ${{ secrets.googleClientIdWeb }} expoProjectId: ${{ secrets.expoProjectId }} + + # Meta tags are not updatable from Expo SDK 49 so add below step + - name: Inject Meta Tags + run: | + sed -i '/<\/head>/i \ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n' ./dist/index.html + + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: '${{ secrets.GITHUB_TOKEN }}' + firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_CROSSPLATFORMKOREA2024 }}' + channelId: live + projectId: crossplatformkorea2024 diff --git a/.gitignore b/.gitignore index e162010..b7a03a3 100644 --- a/.gitignore +++ b/.gitignore @@ -89,4 +89,8 @@ GoogleService-Info.plist # Build *.ipa *.apk -*.aab \ No newline at end of file +*.aab +.firebase +dist/* +!dist/index.html +!dist/apple-app-site-association \ No newline at end of file diff --git a/bun.lockb b/bun.lockb index f65ee5a225883f46562f635800af43085bc2cb35..796f66bfa1dc7bc431d59ed1deff4041d33a8360 100755 GIT binary patch delta 62 zcmZ2_#%k#qtA-ZF7N!>F7M2#)7Pc1l7LF~Pj;Glf<4pBT^^B(5DRN7-C!OX5VlE)& O24bG=NvC-a-vR)v+7{&i delta 62 zcmZ2_#%k#qtA-ZF7N!>F7M2#)7Pc1l7LF~Pj;Gm~7{Fk + + + + + + Cross-Platform Korea + + + + + + + + +
+ + + diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..7c0ca59 --- /dev/null +++ b/firebase.json @@ -0,0 +1,100 @@ +{ + "hosting": [ + { + "target": "staging", + "public": "dist", + "ignore": [ + "firebase.json", + "**/.*", + "node_modules/**" + ], + "headers": [ + { + "source": "/.well-known/apple-app-site-association", + "headers": [ + { + "key": "Content-Type", + "value": "application/json" + } + ] + }, + { + "source": "/**", + "headers": [ + { + "key": "Cache-Control", + "value": "no-cache, no-store, must-revalidate" + } + ] + }, + { + "source": "**/*.@(jpg|jpeg|gif|png|svg|webp|js|css|eot|otf|ttf|ttc|woff|woff2|font.css)", + "headers": [ + { + "key": "Cache-Control", + "value": "max-age=604800" + } + ] + } + ], + "rewrites": [ + { + "source": "/.well-known/apple-app-site-association", + "destination": "/apple-app-site-association" + }, + { + "source": "**", + "destination": "/index.html" + } + ] + }, + { + "target": "app", + "public": "dist", + "ignore": [ + "firebase.json", + "**/.*", + "node_modules/**" + ], + "headers": [ + { + "source": "/.well-known/apple-app-site-association", + "headers": [ + { + "key": "Content-Type", + "value": "application/json" + } + ] + }, + { + "source": "/**", + "headers": [ + { + "key": "Cache-Control", + "value": "no-cache, no-store, must-revalidate" + } + ] + }, + { + "source": "**/*.@(jpg|jpeg|gif|png|svg|webp|js|css|eot|otf|ttf|ttc|woff|woff2|font.css)", + "headers": [ + { + "key": "Cache-Control", + "value": "max-age=604800" + } + ] + } + ], + "rewrites": [ + { + "source": "/.well-known/apple-app-site-association", + "destination": "/apple-app-site-association" + }, + { + "source": "**", + "destination": "/index.html" + } + ] + } + ] +} \ No newline at end of file diff --git a/package.json b/package.json index a5d811a..6f41828 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "lint:app": "eslint --ext .ts,.tsx,.js,.jsx src app", "lint:i18n": "eslint --fix --ext .json --format node_modules/eslint-plugin-i18n-json/formatter.js assets/langs", "fix:deps": "expo install --fix", - "build:web": "expo export --platform web", + "build:web:post": "cp assets/favicon.png dist/", + "build:web": "expo export --platform web && bun build:web:post", "test": "jest --runInBand", "eas:dev:updates": "dotenv -e .env -- eas update --branch development", "eas:preview:android": "dotenv -e .env.production -- eas build --profile preview --platform android",