From db3f511d89a8d158f280934f0b81f9cc85845e57 Mon Sep 17 00:00:00 2001 From: Michel Wilhelm Date: Sat, 7 Nov 2020 22:48:50 -0300 Subject: [PATCH] Testing gh actions --- .dockerignore | 1 + .env.prod | 2 ++ .github/workflows/main.yml | 26 ++++++++++++++++++++++++++ .github/workflows/stage.yml | 26 ++++++++++++++++++++++++++ Dockerfile | 15 +++++++++++++++ src/components/Header/Header.js | 12 ++++++------ 6 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 .dockerignore create mode 100644 .env.prod create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/stage.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/.env.prod b/.env.prod new file mode 100644 index 0000000..af592ab --- /dev/null +++ b/.env.prod @@ -0,0 +1,2 @@ +SKIP_PREFLIGHT_CHECK=true +REACT_APP_API_URL=https://minesweeper.makecodes.dev diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..155e0cb --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,26 @@ +name: Creates a docker image for production + +on: + push: + branches: [master] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Docker Build & Push to GitHub Package + uses: opspresso/action-docker@master + with: + args: --docker + env: + USERNAME: imakecodes + PASSWORD: ${{ secrets.GH_TOKEN }} + REGISTRY: 'docker.pkg.github.com' + DOCKERFILE: 'Dockerfile' + IMAGE_NAME: 'minesweeper-frontend' + TAG_NAME: 'main' + LATEST: 'true' diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml new file mode 100644 index 0000000..942794e --- /dev/null +++ b/.github/workflows/stage.yml @@ -0,0 +1,26 @@ +name: Deploy to stage + +on: + push: + branches: [hotfix/*, release/*] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Docker Build & Push to GitHub Package + uses: opspresso/action-docker@master + with: + args: --docker + env: + USERNAME: imakecodes + PASSWORD: ${{ secrets.GH_TOKEN }} + REGISTRY: 'docker.pkg.github.com' + DOCKERFILE: 'Dockerfile' + IMAGE_NAME: 'minesweeper-frontend' + TAG_NAME: 'stage' + LATEST: 'true' diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..df72db8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM node:12 as build-stage + +WORKDIR /app + +COPY package*.json /app/ + +RUN npm install + +COPY ./ /app/ + +RUN npm run build + +FROM nginx:1.15 +COPY --from=build-stage /app/build/ /usr/share/nginx/html +COPY --from=build-stage /app/nginx.conf /etc/nginx/conf.d/default.conf diff --git a/src/components/Header/Header.js b/src/components/Header/Header.js index 424bd73..228ced9 100644 --- a/src/components/Header/Header.js +++ b/src/components/Header/Header.js @@ -18,33 +18,33 @@ const Header = ({
- + setRows(parseInt(event.target.value))} type="number" value={rows} - id="rows" />
- + setCols(parseInt(event.target.value))} type="number" value={cols} - id="cols" />
- + handleSetMines(event)} type="number" value={mines} - id="mines" />