diff --git a/.github/workflows/deploy-production.yml b/.github/workflows/deploy-production.yml new file mode 100644 index 000000000..68579139f --- /dev/null +++ b/.github/workflows/deploy-production.yml @@ -0,0 +1,116 @@ +name: Deploy suite (Production) + +on: + push: + tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ] + +env: + ECR_REGISTRY: 598984531759.dkr.ecr.us-east-2.amazonaws.com + IMG_PREFIX: base-cms-services + +jobs: + version: + runs-on: ubuntu-latest + steps: + - id: tag_version + run: | + REF=$(echo $GITHUB_REF | cut -d / -f 3) + [[ "$GITHUB_REF" =~ ^refs/tags.*$ ]] && VERSION="$REF" || VERSION="${REF}-${GITHUB_SHA::7}" + echo "version=$VERSION" >> $GITHUB_OUTPUT + outputs: + version: ${{ steps.tag_version.outputs.version }} + + notify-start: + needs: [version] + uses: parameter1/actions/.github/workflows/notify-start.yml@main + secrets: inherit + with: + version: ${{ needs.version.outputs.version }} + + post-deploy-failure: + if: failure() + needs: [notify-start, build, deploy-2] + uses: parameter1/actions/.github/workflows/notify-fail.yml@main + secrets: inherit + with: + slack-thread: ${{ needs.notify-start.outputs.slack-thread }} + + post-deploy-complete: + if: success() + needs: [notify-start, build, deploy-2] + uses: parameter1/actions/.github/workflows/notify-complete.yml@main + secrets: inherit + with: + slack-thread: ${{ needs.notify-start.outputs.slack-thread }} + + build: + needs: [version] + runs-on: ubuntu-latest + strategy: + matrix: + service: + - google-data-api + - graphql-server + - hooks + - oembed + - omail-link-processor + - rss + - sitemaps + steps: + - uses: actions/checkout@v4 + - uses: docker/login-action@v1 + name: Login to ECR + with: + registry: ${{ env.ECR_REGISTRY }} + username: ${{ secrets.AWS_ACCESS_KEY_ID }} + password: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + - name: Build docker image + uses: docker/build-push-action@v2 + with: + context: . + file: services/${{ matrix.service }}/Dockerfile + push: true + build-args: | + SERVICE=${{ matrix.service }} + tags: ${{ env.ECR_REGISTRY }}/${{ env.IMG_PREFIX }}:${{ matrix.service }}-${{ needs.version.outputs.version }} + + deploy-1: + needs: [version, build] + runs-on: ubuntu-latest + strategy: + matrix: + service: + - google-data-api + - oembed + - rss + - sitemaps + steps: + - name: Deploy to Kubernetes + run: | + npx @parameter1/rancher2cli dl \ + --wait basecms-service ${{ matrix.service }} \ + ${{ env.ECR_REGISTRY }}/${{ env.IMG_PREFIX }}:${{ matrix.service }}-${{ needs.version.outputs.version }} + env: + RANCHER_CLUSTERID: ${{ secrets.RANCHER_CLUSTERID_BASECMS }} + RANCHER_TOKEN: ${{ secrets.RANCHER_TOKEN }} + RANCHER_URL: ${{ secrets.RANCHER_URL }} + + deploy-2: + needs: [version, build, deploy-1] + runs-on: ubuntu-latest + strategy: + matrix: + service: + - graphql-server + - hooks + - omail-link-processor + steps: + - name: Deploy to Kubernetes + run: | + npx @parameter1/rancher2cli dl \ + --wait basecms-service ${{ matrix.service }} \ + ${{ env.ECR_REGISTRY }}/${{ env.IMG_PREFIX }}:${{ matrix.service }}-${{ needs.version.outputs.version }} + env: + RANCHER_CLUSTERID: ${{ secrets.RANCHER_CLUSTERID_BASECMS }} + RANCHER_TOKEN: ${{ secrets.RANCHER_TOKEN }} + RANCHER_URL: ${{ secrets.RANCHER_URL }} diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml new file mode 100644 index 000000000..3cd671b6e --- /dev/null +++ b/.github/workflows/node-ci.yml @@ -0,0 +1,33 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 14.x + + - uses: actions/cache@v4 + id: yarn-cache + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + if: steps.yarn-cache.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile + + - run: yarn test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 054d8f6e2..000000000 --- a/.travis.yml +++ /dev/null @@ -1,123 +0,0 @@ -language: node_js -node_js: "14.21" -cache: yarn - -_production-job: &production-job - stage: production - name: SERVICE_NAME - script: scripts/deploy.js SERVICE_NAME - install: skip - env: - - "ENVIRONMENT=production RANCHER_CLUSTERID=c-7p6pt" - -_staging-job: &staging-job - stage: staging - name: SERVICE_NAME - script: scripts/deploy.js SERVICE_NAME - install: skip - env: - - "ENVIRONMENT=staging RANCHER_CLUSTERID=c-gpjnt" - -stages: - - name: test - - - name: production-started - if: tag =~ /^v\d+\.\d+\.\d+$/ - - name: production - if: tag =~ /^v\d+\.\d+\.\d+$/ - - name: production-finished - if: tag =~ /^v\d+\.\d+\.\d+$/ - - - name: staging-started - if: tag is present - - name: staging - if: tag is present - - name: staging-finished - if: tag is present - -jobs: - include: - - stage: test - env: [NODE_ENV=test] - - - <<: *production-job - stage: production-started - name: Deployment Started - script: npx @parameter1/base-cms-website-deployment-tool notify-started - - <<: *staging-job - stage: staging-started - name: Deployment Started - script: npx @parameter1/base-cms-website-deployment-tool notify-started - - ############################# - # vvv ADD SERVICES HERE vvv # - ############################# - - - <<: *production-job - name: GraphQL Server - script: scripts/deploy.js graphql-server - - <<: *staging-job - name: GraphQL Server - script: scripts/deploy.js graphql-server - - - <<: *production-job - name: Sitemaps - script: scripts/deploy.js sitemaps - - <<: *staging-job - name: Sitemaps - script: scripts/deploy.js sitemaps - - - <<: *production-job - name: RSS - script: scripts/deploy.js rss - - <<: *staging-job - name: RSS - script: scripts/deploy.js rss - - - <<: *production-job - name: Hooks - script: scripts/deploy.js hooks - # - <<: *staging-job - # name: Hooks - # script: scripts/deploy.js hooks - - - <<: *production-job - name: oEmbed - script: scripts/deploy.js oembed - - <<: *staging-job - name: oEmbed - script: scripts/deploy.js oembed - - - <<: *production-job - name: Google Data API - script: scripts/deploy.js google-data-api - - <<: *staging-job - name: Google Data API - script: scripts/deploy.js google-data-api - - - <<: *production-job - name: Omail Link Processor - script: scripts/deploy.js omail-link-processor - # - <<: *staging-job - # name: Omail Link Processor - # script: scripts/deploy.js omail-link-processor - - # - <<: *production-job - # name: Algolia Sync - # script: scripts/deploy.js algolia-sync - # - <<: *staging-job - # name: Algolia Sync - # script: scripts/deploy.js algolia-sync - - ############################# - # ^^^ ADD SERVICES HERE ^^^ # - ############################# - - - <<: *production-job - stage: production-finished - name: Deployment Finished - script: npx @parameter1/base-cms-website-deployment-tool notify-finished - - <<: *staging-job - stage: staging-finished - name: Deployment Finished - script: npx @parameter1/base-cms-website-deployment-tool notify-finished