From f9d690313530d8c9253f4eaec338d41077293073 Mon Sep 17 00:00:00 2001 From: Jack Baron Date: Mon, 20 Nov 2023 03:25:39 +0000 Subject: [PATCH] deploy with github pages --- .dockerignore | 27 ----------------- .github/workflows/deploy.yml | 40 +++++++++++++++++++++++++ .github/workflows/docker.yml | 58 ------------------------------------ Dockerfile | 33 -------------------- 4 files changed, 40 insertions(+), 118 deletions(-) delete mode 100644 .dockerignore create mode 100644 .github/workflows/deploy.yml delete mode 100644 .github/workflows/docker.yml delete mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index fa023fb4..00000000 --- a/.dockerignore +++ /dev/null @@ -1,27 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -.pnp.* -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/sdks -!.yarn/versions -# testing -/coverage - -# production -/build - -# misc -.DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local - -npm-debug.log* -yarn-debug.log* -yarn-error.log* diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..4d135831 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,40 @@ +name: Deploy +on: + push: + branches: + - master + +env: + NODE_VERSION: 16.x + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: yarn + - name: Install packages + run: yarn install --immutable + - name: Build + run: yarn run build + - name: Configure GitHub Pages + uses: actions/configure-pages@v3 + - name: Upload Pages Artifact + uses: actions/upload-pages-artifact@v2 + with: + path: build + - name: Deploy + id: deployment + uses: actions/deploy-pages@v2 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 4bcb06d6..00000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Docker Build -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Prepare - id: prepare - run: | - IMAGE_NAME=beatmapper - - GIT_REPO='https://github.com/${{ github.repository }}' - DOCKER_USER=`echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]'` - DOCKER_IMAGE=ghcr.io/$DOCKER_USER/$IMAGE_NAME - - VERSION=`git rev-parse --short HEAD` - if [[ $GITHUB_REF == refs/tags/* ]]; then - VERSION=${GITHUB_REF#refs/tags/v} - fi - - echo ::set-output name=git_repo::${GIT_REPO} - echo ::set-output name=docker_user::${DOCKER_USER} - echo ::set-output name=docker_image::${DOCKER_IMAGE} - echo ::set-output name=version::${VERSION} - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - name: Login to Docker Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ steps.prepare.outputs.docker_user }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and Push - uses: docker/build-push-action@v2 - with: - context: . - push: ${{ (github.ref == 'refs/heads/master') || (contains(github.ref, 'refs/tags/') == true) }} - tags: ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }} - build-args: GIT_REPO=${{ steps.prepare.outputs.git_repo }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new - # Temp fix - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 303babfb..00000000 --- a/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -# syntax = docker/dockerfile:1.3 -FROM node:16-alpine AS builder - -# Create app directory -WORKDIR /usr/app - -# Install app dependencies -COPY ./.yarn ./.yarn -COPY package.json yarn.lock .yarnrc.yml ./ -RUN yarn install --immutable - -# Build source -COPY ./scripts ./scripts -COPY ./config ./config -COPY ./public ./public -COPY ./src ./src -COPY ./tsconfig.json ./ -RUN yarn run build - -# Static Web Server -FROM nginx:alpine - -# Copy Prod Build -COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf -COPY --from=builder /usr/app/build /usr/share/nginx/html - -# Add git repo to metadata -ARG GIT_REPO -LABEL org.opencontainers.image.source=${GIT_REPO} - -# Expose port and run -EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"]