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. 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..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: { @@ -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, }, };