From 8fc8f663f8dc6393b0140c9fc04743bdee85d569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=20Keskim=C3=A4ki?= Date: Tue, 21 Jun 2022 08:52:50 +0300 Subject: [PATCH] Github actions release pipeline --- .circleci/config.yml | 112 ------------------------------- .github/workflows/production.yml | 49 ++++++++++++++ 2 files changed, 49 insertions(+), 112 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/production.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 6e9f6d559..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,112 +0,0 @@ -version: 2.1 -orbs: - dockerhub: circleci/docker@0.5.1 -jobs: - test-backend: - docker: - - image: circleci/node:8 - - image: circleci/postgres:10.1-alpine-ram - steps: - - checkout - - restore_cache: - key: dependency-cache-backend-{{ checksum "backend/package.json" }} - - run: cd backend && npm install - - save_cache: - key: dependency-cache-backend-{{ checksum "backend/package.json" }} - paths: - - ./backend/node_modules - - run: cd backend && npm run create_test_db - - run: cd backend && ADMIN_PW=test TOKEN=test SECRET=test BACKEND=true npm test - test-frontend: - docker: - - image: circleci/node:8 - steps: - - checkout - - restore_cache: - key: dependency-cache-frontend-{{ checksum "labtool2.0/package.json" }} - - run: cd labtool2.0 && npm install - - save_cache: - key: dependency-cache-frontend-{{ checksum "labtool2.0/package.json" }} - paths: - - ./labtool2.0/node_modules - - run: cd labtool2.0 && FRONTEND=true CI=true npm test - publish-backend-trunk: - executor: dockerhub/machine - steps: - - checkout - - dockerhub/check - - dockerhub/build: - path: backend - image: toska/labtool-backend - dockerfile: backend/Dockerfile - tag: 'test' - - dockerhub/push: - image: toska/labtool-backend - tag: 'test' - publish-backend-master: - executor: dockerhub/machine - steps: - - checkout - - dockerhub/check - - dockerhub/build: - path: backend - image: toska/labtool-backend - dockerfile: backend/Dockerfile - tag: 'staging' - - dockerhub/push: - image: toska/labtool-backend - tag: 'staging' - publish-frontend-trunk: - executor: dockerhub/machine - steps: - - checkout - - dockerhub/check - - dockerhub/build: - image: toska/labtool - dockerfile: Dockerfile.test - tag: 'test' - - dockerhub/push: - image: toska/labtool - tag: 'test' - publish-frontend-master: - executor: dockerhub/machine - steps: - - checkout - - dockerhub/check - - dockerhub/build: - image: toska/labtool - dockerfile: Dockerfile - tag: 'staging' - - dockerhub/push: - image: toska/labtool - tag: 'staging' - -workflows: - test-build-deploy: - jobs: - - test-backend - - test-frontend - - publish-backend-trunk: - requires: - - test-backend - filters: - branches: - only: trunk - - publish-backend-master: - requires: - - test-backend - filters: - branches: - only: master - - publish-frontend-trunk: - requires: - - test-frontend - filters: - branches: - only: trunk - - publish-frontend-master: - requires: - - test-frontend - filters: - branches: - only: master diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml new file mode 100644 index 000000000..8680bb312 --- /dev/null +++ b/.github/workflows/production.yml @@ -0,0 +1,49 @@ +name: Release to production + +on: + push: + branches: + - master + +jobs: + release-frontend: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Login to dockerhub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker images + uses: docker/build-push-action@v2 + with: + context: . + tags: toska/labtool:test + push: true + build-args: | + NODE_ENV=production + + release-backend: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Login to dockerhub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker images + uses: docker/build-push-action@v2 + with: + context: ./backend + tags: toska/labtool-backend:test + push: true + build-args: | + NODE_ENV=production