diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..24c6a20 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,67 @@ +name: Build and Publish Arena Site + +on: + push: + branches: + - "main" + - "deploy" + +jobs: + rapid: + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + + - name: Set environment variables + uses: allenevans/set-env@v2.0.0 + with: + ARENA_S3_BUCKET: ${{ secrets.ARENA_S3_BUCKET }} + CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} + NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN: ${{ secrets.NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN }} + NEXT_PUBLIC_MAPBOX_STYLE_EXPLORE: ${{ secrets.NEXT_PUBLIC_MAPBOX_STYLE_EXPLORE }} + NEXT_PUBLIC_DATA_API: ${{ secrets.NEXT_PUBLIC_DATA_API }} + + - name: Checkout current repository + uses: actions/checkout@v2 + + - name: Use Node.js 18 + uses: actions/setup-node@v1 + with: + node-version: 18 + + - name: Install Yarn + run: | + npm install -g yarn + + - name: Install dependencies + run: | + cd web_app && yarn install && yarn add sharp + + - name: Configure path alias + run: | + echo '{ "compilerOptions": { "baseUrl": ".", "paths": { "@/*": ["src/*"] } } }' > web_app/jsconfig.json + + - name: Build rapid frontend + run: | + cd web_app && yarn build + + - uses: actions/setup-python@v2 + with: + python-version: "3.8" + + - name: Install aws cli + run: | + python -m pip install --upgrade pip + pip install awscli + + - name: Push data to S3 and clean CloudFront cache + if: ${{ success() }} + run: | + aws s3 sync web_app/out/ s3://${{ env.ARENA_S3_BUCKET }}/ --acl public-read --delete + aws cloudfront create-invalidation --distribution-id=${{ env.CLOUDFRONT_DISTRIBUTION_ID }} --paths=/ + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} \ No newline at end of file diff --git a/web_app/.gitignore b/web_app/.gitignore index 5cc2717..ce85afa 100644 --- a/web_app/.gitignore +++ b/web_app/.gitignore @@ -39,4 +39,5 @@ next-env.d.ts # yarn -.idea/ \ No newline at end of file +.idea/ +.env \ No newline at end of file diff --git a/web_app/src/pages/_app.jsx b/web_app/src/pages/_app.jsx index ed566a9..e28c84f 100644 --- a/web_app/src/pages/_app.jsx +++ b/web_app/src/pages/_app.jsx @@ -3,7 +3,7 @@ import 'mapbox-gl/dist/mapbox-gl.css'; import { ChakraProvider } from '@chakra-ui/react'; import theme from '@/config/theme'; -import Layout from '@/components/Layout'; +import Layout from '@/components/layout'; import { AppWrapper } from '@/store/context'; import Head from 'next/head'; import { diff --git a/web_app/yarn.lock b/web_app/yarn.lock index 93ed6d1..4329e4e 100644 --- a/web_app/yarn.lock +++ b/web_app/yarn.lock @@ -5451,3 +5451,4 @@ zwitch@^2.0.0, zwitch@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/zwitch/-/zwitch-2.0.4.tgz#c827d4b0acb76fc3e685a4c6ec2902d51070e9d7" integrity sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A== + \ No newline at end of file