diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index de6774e..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,29 +0,0 @@ -version: 2 -jobs: - build: - docker: - - image: circleci/node:14.18.0-browsers - working_directory: ~/twhelpwebsite - steps: - - checkout - - setup_remote_docker: - version: 20.10.2 - # start proprietary DB using private Docker image - # with credentials stored in the UI - - run: | - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD - # build the application image - - run: docker build -t $DOCKER_LOGIN/twhelp-website:latest . - - # deploy the image - - run: docker push $DOCKER_LOGIN/twhelp-website:latest -workflows: - version: 2 - deploy_prod: - jobs: - - build: - context: TWHelp - filters: - branches: - only: - - master diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..6b932f0 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,48 @@ +name: Build and push to registry + +on: + push: + tags: + - '*' + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} + + - name: Set up 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 DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.REGISTRY_LOGIN }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Push to Docker Hub + uses: docker/build-push-action@v2 + with: + context: . + build-args: | + PLAUSIBLE_CUSTOM_DOMAIN=${{ secrets.PLAUSIBLE_CUSTOM_DOMAIN }} + VERSION=${{ steps.get_version.outputs.VERSION }} + tags: | + ${{ secrets.REGISTRY_NAME }}/twhelp-website:latest + ${{ secrets.REGISTRY_NAME }}/twhelp-website:${{ steps.get_version.outputs.VERSION }} + file: ./Dockerfile + push: true diff --git a/Dockerfile b/Dockerfile index 3623c19..b73b18c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,9 @@ FROM node:14.18.1-alpine as build-deps -ENV NODE_ENV=production +ARG PLAUSIBLE_CUSTOM_DOMAIN="" + +ENV PLAUSIBLE_CUSTOM_DOMAIN=$PLAUSIBLE_CUSTOM_DOMAIN \ + NODE_ENV=production RUN apk --no-cache add shadow \ gcc \ @@ -16,9 +19,9 @@ RUN apk --no-cache add shadow \ zlib-dev \ file \ pkgconf -RUN npm install --global gatsby-cli@3.3.0 WORKDIR /usr/src/app COPY package.json yarn.lock ./ +RUN yarn global add gatsby-cli@3.3.0 RUN yarn COPY . ./ RUN yarn build diff --git a/gatsby-config.js b/gatsby-config.js index a0cb5fa..2f7822f 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -1,19 +1,19 @@ -const baseUrl = 'tribalwarshelp.com'; -const siteUrl = 'https://' + baseUrl; -const apiUrl = 'https://api.' + baseUrl; +const DOMAIN = 'tribalwarshelp.com'; +const SITE_URL = 'https://' + DOMAIN; +const API_URL = 'https://api.' + DOMAIN; module.exports = { siteMetadata: { title: `TWHelp`, description: `Tools for the popular online game TribalWars.`, - dcbotUrl: 'https://dcbot.' + baseUrl, - apiUrl, + dcbotUrl: 'https://dcbot.' + DOMAIN, + apiUrl: API_URL, author: 'Dawid Wysokiński', authorEmail: 'contact@dwysokinski.me', contactUrl: 'https://dwysokinski.me/#contact', scriptsUrl: 'https://github.com/tribalwarshelp/scripts', - siteUrl, - baseUrl, + siteUrl: SITE_URL, + baseUrl: DOMAIN, }, plugins: [ `gatsby-plugin-react-helmet`, @@ -57,8 +57,8 @@ module.exports = { { resolve: 'gatsby-plugin-robots-txt', options: { - host: siteUrl, - sitemap: siteUrl + '/sitemap.xml', + host: SITE_URL, + sitemap: SITE_URL + '/sitemap.xml', env: { development: { policy: [{ userAgent: '*', disallow: ['/'] }], @@ -77,7 +77,14 @@ module.exports = { // This is the field under which it's accessible fieldName: 'twhelp', // URL to query from - url: apiUrl + '/graphql', + url: API_URL + '/graphql', + }, + }, + { + resolve: `@kichiyaki/gatsby-plugin-plausible`, + options: { + domain: DOMAIN, + customDomain: process.env.PLAUSIBLE_CUSTOM_DOMAIN, }, }, ], diff --git a/package.json b/package.json index 3eca3dd..aa29ba4 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "version": "0.1.0", "author": "Dawid Wysokiński ", "dependencies": { + "@kichiyaki/gatsby-plugin-plausible": "^0.0.8", "@kichiyaki/roboto": "^1.0.0", "@material-ui/core": "^4.11.0", "@material-ui/icons": "^4.9.1", diff --git a/yarn.lock b/yarn.lock index bb0334d..d90676d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -988,6 +988,13 @@ dependencies: regenerator-runtime "^0.13.4" +"@babel/runtime@^7.9.2": + version "7.16.3" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.16.3.tgz#b86f0db02a04187a3c17caa77de69840165d42d5" + integrity sha512-WBwekcqacdY2e9AF/Q7WLFUWmdJGJTkbjqTjoMDgXkVZ3ZRUvOPsLb5KdwISoQVsbP+DQzVZW4Zhci0DvpbNTQ== + dependencies: + regenerator-runtime "^0.13.4" + "@babel/standalone@^7.12.6": version "7.13.17" resolved "https://registry.yarnpkg.com/@babel/standalone/-/standalone-7.13.17.tgz#921b82a11a80ce824589516736d629efc53297aa" @@ -1572,6 +1579,15 @@ "@babel/runtime" "^7.7.2" regenerator-runtime "^0.13.3" +"@kichiyaki/gatsby-plugin-plausible@^0.0.8": + version "0.0.8" + resolved "https://registry.yarnpkg.com/@kichiyaki/gatsby-plugin-plausible/-/gatsby-plugin-plausible-0.0.8.tgz#94f53c5a8f768b934228e4f43c5493c38885152b" + integrity sha512-DO03Z6NHRiwh8XHJtBJcLxMZ1a8cDjYM0inuGmNI33ea7fV4wdGVF5uHidlbdlls2hLfYPDkjOc0y2Yz3Ff/nw== + dependencies: + "@babel/runtime" "^7.9.2" + minimatch "3.0.4" + react "^17.0.2" + "@kichiyaki/roboto@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@kichiyaki/roboto/-/roboto-1.0.0.tgz#6f5dfb40e2423940588946c952490b123ca8088b" @@ -10976,7 +10992,7 @@ react-transition-group@^4.4.0: loose-envify "^1.4.0" prop-types "^15.6.2" -react@^17.0.0: +react@^17.0.0, react@^17.0.2: version "17.0.2" resolved "https://registry.yarnpkg.com/react/-/react-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037" integrity sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==