Skip to content

Commit

Permalink
Patch command usage in GitHub Pages deployment action (Some patching …
Browse files Browse the repository at this point in the history
…still required for PWA)
  • Loading branch information
malee31 committed Sep 8, 2024
1 parent c88bd39 commit 8be33bb
Show file tree
Hide file tree
Showing 22 changed files with 125 additions and 62 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,25 @@ jobs:
uses: actions/setup-node@v3

- name: Install Dependencies
run: npm install --legacy-peer-deps --save-dev --include=dev
run: npm install --save-dev --include=dev

- name: Setup Expo
uses: expo/expo-github-action@v7
uses: expo/expo-github-action@v8
with:
expo-version: latest
packager: npm

- name: Build Web App with Expo
run: npx expo export:web
run: npx expo export -p web --output-dir web-build/

- name: Modify build
run: |
npx workbox-cli generateSW workbox-config.js
cp assets/web-privacy-policy.html web-build/privacy-policy.html
cp web-build/index.html web-build/404.html
cp assets/pwa-manifest.json web-build/manifest.json
cp -r assets/pwa-icons/chrome-icon web-build/pwa/chrome-icon
cp -r assets/pwa-icons/adaptable-icon web-build/pwa/adaptable-icon
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4.2.5
uses: JamesIves/github-pages-deploy-action@v4.6.4
with:
branch: gh-pages
folder: web-build
55 changes: 0 additions & 55 deletions assets/pwa-manifest.json

This file was deleted.

54 changes: 54 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="%LANG_ISO_CODE%">
<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"/>
<link rel="manifest" href="/manifest.json"/>
<title>%WEB_TITLE%</title>
<!-- Workbox Script for PWA Support -->
<script>
if("serviceWorker" in navigator) {
window.addEventListener("load", () => {
navigator.serviceWorker
.register("/sw.js")
.then(registration => {
console.log("Service Worker registered with scope:", registration.scope);
})
.catch(error => {
console.error("Service Worker registration failed:", error);
});
});
}
</script>
<!-- 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>
</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>
</body>
</html>
55 changes: 55 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"background_color": "#FFFFFF",
"description": "Team4159 CardinalBotics Sign-In App",
"display": "standalone",
"lang": "en-US",
"name": "CardinalHours",
"scope": "/ReactNativeCardinalBoticsApp/",
"short_name": "CardinalHours",
"start_url": "/ReactNativeCardinalBoticsApp/",
"theme_color": "#FFFFFF",
"orientation": "portrait",
"related_applications": [
{
"platform": "play",
"url": "https://play.google.com/store/apps/details?id=com.team4159.cardinalboticsapp",
"id": "com.team4159.cardinalboticsapp"
}
],
"prefer_related_applications": true,
"icons": [
{
"src": "/pwa-icons/chrome-icon/chrome-icon-144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "/pwa-icons/chrome-icon/chrome-icon-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/pwa-icons/chrome-icon/chrome-icon-512.png",
"sizes": "512x512",
"type": "image/png"
},
{
"src": "/pwa-icons/adaptable-icon/adaptable-icon-144.png",
"sizes": "144x144",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/pwa-icons/adaptable-icon/adaptable-icon-192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/pwa-icons/adaptable-icon/adaptable-icon-512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
]
}
11 changes: 11 additions & 0 deletions workbox-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
globDirectory: 'web-build/',
globPatterns: [
'**/*.{js,html,png,ico,json}'
],
swDest: 'web-build/sw.js',
ignoreURLParametersMatching: [
/^utm_/,
/^fbclid$/
]
};

0 comments on commit 8be33bb

Please sign in to comment.