diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml deleted file mode 100644 index 9f8a8e82..00000000 --- a/.github/workflows/CI.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: CI pipeline - -on: - push : - branches : [ "**" ] - pull_request: - types: [ opened ] - -jobs: - lint: - runs-on: ubuntu-latest - strategy: - matrix: - node: [ 14, 16 ] - defaults: - run: - shell: bash - - steps: - - name: 🏗 Setup repo - uses: actions/checkout@v3 - - - name: 🏗 Setup node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - cache: yarn - cache-dependency-path: yarn.lock - - - name: 🏗 Config files - run: | - echo "$FIREBASE_CONFIG_DEV" > ./src/config/firebaseAuthConfig.js - - - name: 📦 Install dependencies - run: yarn install --pure-lockfile --non-interactive - - - name: 📦 Run lint - run: npx eslint ./src - - # Test job - - deploy: - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} - runs-on: ubuntu-latest - needs: lint - env: - IMAGE_NAME: ${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }} - - steps: - - name: 🏗 Setup repo - uses: actions/checkout@v3 - - - name: 🏗 Config files - run: | - echo "$FIREBASE_CONFIG_DEV" > ./src/config/firebaseAuthConfig.js - echo "$RCLONE_CONFIG" > ./config/rclone.conf - - - name: 📦 Docker login - run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_ACCESS_TOKEN }} - - - name: 📦 Docker push image - run: | - docker build . -t "$IMAGE_NAME" - docker push "$IMAGE_NAME" - docker tag "$IMAGE_NAME" ${{ secrets.DOCKER_REPOSITORY }}:latest - docker push ${{ secrets.DOCKER_REPOSITORY }}:latest diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..b83186fe --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,40 @@ +name: build, test and lint + +on: + push : + branches : [ "**" ] + pull_request: + types: [ opened ] + +jobs: + build-test: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + + steps: + - name: 🏗 Setup repo + uses: actions/checkout@v3 + + - name: 🏗 Setup node + uses: actions/setup-node@v3 + with: + node-version: lts/* + cache: yarn + cache-dependency-path: yarn.lock + + - name: 🏗 Config files + run: | + echo "$FIREBASE_CONFIG_DEV" > ./src/config/firebaseAuthConfig.js + env: + FIREBASE_CONFIG_DEV: ${{ secrets.FIREBASE_CONFIG_DEV }} + + - name: 📦 Install dependencies + run: yarn install --pure-lockfile --non-interactive + + - name: 📦 Run test + run: yarn test + + - name: 📦 Run lint + run: yarn lint diff --git a/.github/workflows/submit.yml b/.github/workflows/submit.yml new file mode 100644 index 00000000..a59c1fe7 --- /dev/null +++ b/.github/workflows/submit.yml @@ -0,0 +1,43 @@ +name: submit image to dockerhub + +on: + push : + branches : [ master, develop ] + + +jobs: + deploy: + runs-on: ubuntu-latest + env: + IMAGE_NAME: ${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }} + FIREBASE_CONFIG_DEV: ${{ secrets.FIREBASE_CONFIG_DEV }} + FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }} + RCLONE_CONFIG: ${{ secrets.RCLONE_CONFIG }} + + steps: + - name: 🏗 Setup repo + uses: actions/checkout@v3 + + - name: 🏗 Config dev files + if: github.ref == 'refs/heads/develop' + run: | + echo "$FIREBASE_CONFIG_DEV" > ./src/config/firebaseAuthConfig.js + echo "$RCLONE_CONFIG" > ./config/rclone.conf + echo "TAG=latest" >> "$GITHUB_ENV" + + - name: 🏗 Config prod files + if: github.ref == 'refs/heads/master' + run: | + echo "$FIREBASE_CONFIG" > ./src/config/firebaseAuthConfig.js + echo "$RCLONE_CONFIG" > ./config/rclone.conf + echo "TAG=stable" >> "$GITHUB_ENV" + + - name: 📦 Docker login + run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_ACCESS_TOKEN }} + + - name: 📦 Docker push image + run: | + docker build . -t "$IMAGE_NAME" + docker push "$IMAGE_NAME" + docker tag "$IMAGE_NAME" ${{ secrets.DOCKER_REPOSITORY }}:"$TAG" + docker push ${{ secrets.DOCKER_REPOSITORY }}:"$TAG" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index ae034ee4..00000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,52 +0,0 @@ -stages: - - lint - - build - -lint: - stage: lint - image: node:12.2.0-alpine - before_script: - - npm install - script: - - npx eslint ./src - allow_failure: true - -build: - services: - - docker:dind - image: docker:stable - stage: build - variables: - IMAGE_NAME: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" - before_script: - - cat $FIREBASE_CONFIG > ./src/config/firebaseAuthConfig.js - - cat $RCLONE_CONFIG > ./config/rclone.conf - script: - - echo "Building image" - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker build . -t $IMAGE_NAME - - docker push $IMAGE_NAME - - docker tag $IMAGE_NAME $CI_REGISTRY_IMAGE:latest - - docker push $CI_REGISTRY_IMAGE:latest - except: - - master - - configuracao-ci - -build stable: - services: - - docker:dind - image: docker:stable - stage: build - variables: - IMAGE_NAME: "$CI_REGISTRY_IMAGE:stable" - before_script: - - cat $FIREBASE_CONFIG > ./src/config/firebaseAuthConfig.js - - cat $RCLONE_CONFIG > ./config/rclone.conf - script: - - echo "Building image" - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker build . -t $IMAGE_NAME - - docker push $IMAGE_NAME - only: - - master - - configuracao-ci diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml deleted file mode 100644 index da9e7594..00000000 --- a/docker-compose.prod.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: "3" -services: - mgob: - container_name: mgob - environment: - - MONGODB_USERNAME=${MONGODB_USERNAME} - - MONGODB_PASSWORD=${MONGODB_PASSWORD} - image: stefanprodan/mgob:edge - command: ./mgob -LogLevel=info - volumes: - - ./config:/config - - /mgob/storage:/storage - - /mgob/tmp:/tmp - - /mgob/data:/data - depends_on: - - mongo diff --git a/package.json b/package.json index 247fd219..8d480ff0 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ "start:dev": "nodemon index.js", "dev": "node server.js", "test": "jest", - "test:coverage": "jest --coverage" + "test:coverage": "jest --coverage", + "lint": "npx eslint ./src", + "lint:fix": "npx eslint ./src --fix" }, "dependencies": { "@sentry/node": "5.18.0",