Skip to content

Commit

Permalink
Deploy frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
bakaq committed Oct 16, 2024
1 parent 972b0c7 commit 9cf8eea
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/github_pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Deploy to Github Pages
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Configure Github Pages
uses: actions/configure-pages@v3
- name: Checkout repo
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: npm install
working-directory: ./frontend
run: |
nix develop --command npm install
- name: Build
working-directory: ./frontend
env:
REACT_APP_API_ROOT: "https://api.bakaq.net/market-helper"
run: |
nix develop --command npm run build
- name: Upload Github Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: "./frontend/build/"
deploy:
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{steps.deployment.outputs.page_url}}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to Github Pages
id: deployment
uses: actions/deploy-pages@v4

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "frontend",
"version": "0.1.0",
"private": true,
"homepage": "https://bakaq.net/market-helper",
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { useState, useEffect } from 'react';

// TODO: Configure it at build-time
function api_root() {
const hostname = window.location.hostname;
return `http://${hostname}:8000`;
return process.env.REACT_APP_API_ROOT || "http://localhost:8000";
}

const PRECISION = 3;
Expand Down Expand Up @@ -194,7 +192,7 @@ function ItemCard({ itemId, itemData, getItems }) {
:
(
<div className="item-card">
<h3>{itemData.name}</h3>
<h3>{itemData.name}</h3>
<div className="item-card-header">
<div className="item-price">R$ {itemData.price.toFixed(2)}</div>
<div className="item-weight">{itemData.weight.toPrecision(PRECISION)}g</div>
Expand Down

0 comments on commit 9cf8eea

Please sign in to comment.