From ff7118bc69c346db51c6597df96f9be672599f00 Mon Sep 17 00:00:00 2001 From: Daniel Bisgrove Date: Tue, 6 Dec 2022 08:58:08 -0500 Subject: [PATCH] Migrate Travis Ci to Github actions Fixing codecov chrome issues Removing bash codeCov as we already run it and removing chrome ext, as we run codecov browserless Fixing package.json issue with trailing comma Setting up staging and production deployment using deployment environment vars and secrets Removing Travis CI from repo. --- .github/workflows/ci.yml | 65 ++++++++++++++++++++++++++++++++++ .travis.yml | 75 ---------------------------------------- package.json | 4 +++ 3 files changed, 69 insertions(+), 75 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..66644e52 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,65 @@ +name: CI + +on: + push: + branches: [master, staging] + pull_request: + branches: [master, staging] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + CHROME_BIN: /usr/bin/google-chrome + +permissions: + id-token: write + contents: write + +jobs: + test: + name: Checks & Build Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 12 + - name: Install Dependenices + run: yarn + - name: Run Lint & Prettier Tests + run: | + yarn lint:type + yarn prettier:check + - name: Build Staging + run: yarn build:stage + - name: Build Production + run: yarn build:prod + - name: Run Test with CodeCov + run: yarn test:codecov + - name: Code coverage test + uses: codecov/codecov-action@v1.1.1 + + deploy: + name: Deployment + runs-on: ubuntu-latest + if: | + (github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/master') + && github.event_name == 'push' + environment: ${{ github.ref == 'refs/heads/master' && 'prod' || 'stage' }} + needs: test + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 12 + - name: Install Dependenices + run: yarn + - name: Build + run: yarn build:${{vars.ENVIRONMENT}} + - uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: '${{ secrets.AWS_IAM_ROLE_ARN }}' + aws-region: us-east-1 + - run: aws s3 sync dist s3://${{ secrets.AWS_S3_BUCKET }} --region us-east-1 --acl public-read --cache-control "max-age=300" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ed7751a6..00000000 --- a/.travis.yml +++ /dev/null @@ -1,75 +0,0 @@ -language: node_js -node_js: '12' - -branches: - only: - - master - - staging - -addons: - chrome: stable - -services: - - xvfb - -stages: - - name: test - - name: release - if: type = push - -cache: - yarn: true - directories: - - node_modules - -jobs: - include: - - stage: test - - before_install: - - export CHROME_BIN=/usr/bin/google-chrome - - script: - - ng test --watch=false --code-coverage - - ng lint --type-check - - yarn prettier:check - - ng build -c staging - - ng build -c production - - after_success: - - bash <(curl -s https://codecov.io/bash) - - - name: 'Release Staging' - stage: release - if: branch = staging - - script: ng build -c staging - - deploy: - - provider: s3 - bucket: 'cru-mobilecontentadmin-staging' - region: us-east-1 - skip_cleanup: true - local_dir: dist - acl: public_read - on: - branch: staging - - - name: 'Release Production' - stage: release - if: branch = master - - script: ng build -c production - - deploy: - - provider: s3 - bucket: 'cru-mobilecontentadmin-prod' - region: us-east-1 - skip_cleanup: true - local_dir: dist - acl: public_read - on: - branch: master - -notifications: - email: false diff --git a/package.json b/package.json index 10a2532a..85280cfa 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,12 @@ "ng": "ng", "start": "ng serve", "build": "ng build", + "build:stage": "ng build -c staging", + "build:prod": "ng build -c production", "test": "ng test", + "test:codecov": "ng test --watch=false --browsers=ChromeHeadless --code-coverage", "lint": "ng lint", + "lint:type": "ng lint --type-check", "e2e": "ng e2e", "prettier:check": "prettier '{{src,e2e,__{tests,mocks}__}/**/*.{js,json,ts,tsx,html},./*.{js,json,ts,tsx,yml,html}}' --list-different", "prettier:write": "prettier '{{src,e2e,__{tests,mocks}__}/**/*.{js,json,ts,tsx,html},./*.{js,json,ts,tsx,yml,html}}' --write"