Skip to content

Commit

Permalink
ci: setup web hosting
Browse files Browse the repository at this point in the history
  • Loading branch information
hyochan committed Aug 14, 2024
1 parent d7a9d78 commit 89713db
Show file tree
Hide file tree
Showing 9 changed files with 261 additions and 11 deletions.
19 changes: 16 additions & 3 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
{
"projects": {
"default": ""
}
}
"default": "crossplatformkorea2024"
},
"targets": {
"crossplatformkorea2024": {
"hosting": {
"staging": [
"cpk-staging"
],
"app": [
"crossplatformkorea2024"
]
}
}
},
"etags": {}
}
57 changes: 57 additions & 0 deletions .github/workflows/deploy-pr.yml
Original file line number Diff line number Diff line change
@@ -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 \
<meta property="og:image" content="https://crossplatformkorea.com/img/hero.svg" />\n\
<meta property="og:type" content="website" />\n\
<meta property="og:url" content="https://cpk.dooboolab.com" />\n\
<meta property="og:description" content="Cross-Platform Korea Community" />\n\
<meta property="og:title" content="Cross-Platform Korea" />\n\
<meta property="twitter:card" content="Cross-Platform Korea" />\n\
<meta property="twitter:url" content="https://cpk.dooboolab.com" />\n\
<meta property="twitter:title" content="Cross-Platform Korea" />\n\
<meta property="twitter:description" content="Cross-Platform Korea Community" />\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
39 changes: 33 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,47 @@ 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

- 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 \
<meta property="og:image" content="https://crossplatformkorea.com/img/hero.svg" />\n\
<meta property="og:type" content="website" />\n\
<meta property="og:url" content="https://cpk.dooboolab.com" />\n\
<meta property="og:description" content="Cross-Platform Korea Community" />\n\
<meta property="og:title" content="Cross-Platform Korea" />\n\
<meta property="twitter:card" content="Cross-Platform Korea" />\n\
<meta property="twitter:url" content="https://cpk.dooboolab.com" />\n\
<meta property="twitter:title" content="Cross-Platform Korea" />\n\
<meta property="twitter:description" content="Cross-Platform Korea Community" />\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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,8 @@ GoogleService-Info.plist
# Build
*.ipa
*.apk
*.aab
*.aab
.firebase
dist/*
!dist/index.html
!dist/apple-app-site-association
Binary file modified bun.lockb
Binary file not shown.
11 changes: 11 additions & 0 deletions dist/apple-app-site-association
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"applinks": {
"apps": [],
"details": [
{
"appID": "LCXV255WTL.com.dooboolab.cpk",
"paths": ["*"]
}
]
}
}
37 changes: 37 additions & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Cross-Platform Korea</title>
<!-- The `react-native-web` recommended style reset: https://necolas.github.io/react-native-web/docs/setup/#root-element -->
<style id="expo-reset">
/* These styles make the body full-height */
html,
body {
height: 100%;
}
/* These styles disable body scrolling if you are using <ScrollView> */
body {
overflow: hidden;
}
/* These styles make the root element full-height */
#root {
display: flex;
height: 100%;
flex: 1;
}
</style>
<link rel="shortcut icon" href="/favicon.ico" /></head>

<body>
<!-- Use static rendering with Expo Router to support running without JavaScript. -->
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<!-- The root element for your Expo app. -->
<div id="root"></div>
<script src="/_expo/static/js/web/entry-e6239ec93fabe58328367976b46c23ae.js" defer></script>
</body>
</html>
100 changes: 100 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 89713db

Please sign in to comment.