From c402ebd6bdd466da5c24dca9b68590e12408dac5 Mon Sep 17 00:00:00 2001 From: Conor Mongey Date: Thu, 10 Nov 2022 23:56:59 +0000 Subject: [PATCH 1/3] Publish to gh-pages branch on commit to masster branch --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7bf52b2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: Build and Deploy +on: + push: + branches: + - master + +permissions: + contents: write +jobs: + build-and-deploy: + concurrency: ci-${{ github.ref }} + runs-on: ubuntu-latest + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 + + - name: Install and Build 🔧 + uses: actions/setup-node@v3 + with: + node-version: 14 + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + - run: | + yarn install --frozen-lockfile + yarn run build + - name: Deploy 🚀 + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: dist # The folder the action should deploy. From 88a3df65a457ebf8046311df8d589216d745bf39 Mon Sep 17 00:00:00 2001 From: Conor Mongey Date: Thu, 10 Nov 2022 23:57:32 +0000 Subject: [PATCH 2/3] Allow a default group to be set --- app/router.js | 3 ++- app/routes/worldcup.ts | 7 ++++++- config/environment.js | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/router.js b/app/router.js index a740035..0f437a4 100644 --- a/app/router.js +++ b/app/router.js @@ -7,5 +7,6 @@ export default class Router extends EmberRouter { } Router.map(function () { - this.route('worldcup', { path: ':id' }); + this.route('worldcup', { path: '/' }); + this.route('worldcup', { path: '/:id' }); }); diff --git a/app/routes/worldcup.ts b/app/routes/worldcup.ts index 7a3f718..49afe99 100644 --- a/app/routes/worldcup.ts +++ b/app/routes/worldcup.ts @@ -3,6 +3,7 @@ import { inject as service } from '@ember/service'; import Api from 'worldcup/services/api'; import { taskFor } from 'ember-concurrency-ts'; import Sweepstakes, { Player } from 'worldcup/services/sweepstakes'; +import ENV from 'worldcup/config/environment'; export default class WorldCup extends Route { @service declare api: Api; @@ -10,8 +11,12 @@ export default class WorldCup extends Route { async model(params: { id: string }) { var players: Player[]; + var id = params.id; + if (id === undefined) { + id = ENV.APP.default_group as string; + } try { - let response = await fetch(`/players/${params.id}.json`); + let response = await fetch(`/players/${id}.json`); let loadedData = await response.json(); players = loadedData.players; } catch { diff --git a/config/environment.js b/config/environment.js index df06094..48b80b8 100644 --- a/config/environment.js +++ b/config/environment.js @@ -20,6 +20,7 @@ module.exports = function (environment) { APP: { // Here you can pass flags/options to your application instance // when it is created + default_group: process.env.DEFAULT_GROUP, }, }; From 04b8453463ae9ad6d55131507284d9f94409e50d Mon Sep 17 00:00:00 2001 From: Conor Mongey Date: Fri, 11 Nov 2022 00:00:45 +0000 Subject: [PATCH 3/3] Add support for deploying to gh_pages w/t rootURL prefix --- config/environment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environment.js b/config/environment.js index 48b80b8..0e2e79e 100644 --- a/config/environment.js +++ b/config/environment.js @@ -4,7 +4,7 @@ module.exports = function (environment) { let ENV = { modulePrefix: 'worldcup', environment, - rootURL: '/', + rootURL: process.env.ROOT_URL ? process.env.ROOT_URL : '/', locationType: 'hash', EmberENV: { FEATURES: {