Github actions delivery bot

257 views Asked by At

We have set up Github actions for ci/cd pipelines, and it was working as expected a few days back. We use GitHub pr comments (/deploy staging) to deploy the code to the AWS S3 bucket and everything was working as expected, But now when we comment on pr(pull request), deployment does not trigger instead it triggers at midnight after 10 hours. Here are my files.

  1. workflows/deploy.yml

    name: 'Deploy' on: ['deployment']

jobs: deployment: name: 'Deploy to ${{ github.event.deployment.environment }}' runs-on: ubuntu-latest steps:

  - name: Deployment pending
    uses: deliverybot/deployment-status@master
    with:
      state: pending
      token: '${{ github.token }}'

  - name: Copy Repo Files
    uses: actions/checkout@v1

  - name: Set Variables
    id: variables
    run: |
      if [ "$ENVIRONMENT" == "production" ]; then
        echo ::set-output name=DEPLOY_BUCKET::$PROD_BUCKET
        export PUBLIC_URL=https://app.virtualcombine.com/
      else
        echo ::set-output name=DEPLOY_BUCKET::$STAGING_BUCKET
        export PUBLIC_URL=https://staging-app.virtualcombine.com/
      fi
      export VERSION="$(node -pe "require('./package.json').version")"
      export COMMIT="$(sed -e 's/^\(.\{9\}\).*/\1/' <<< $(git rev-parse --short HEAD))"
      echo ::set-output name=SOURCE_PATH::$VERSION/$COMMIT/$ENVIRONMENT
    env:
      ENVIRONMENT: ${{ github.event.deployment.environment }}
      PROD_BUCKET: ${{ secrets.PROD_S3_UI_BUCKET }}
      STAGING_BUCKET: ${{ secrets.STAGING_S3_UI_BUCKET }}

  - name: Configure AWS credentials
    uses: aws-actions/configure-aws-credentials@v1
    with:
      aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
      aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
      aws-region: us-east-2

  - name: 'Deploy to ${{ github.event.deployment.environment }}'
    run: |
      aws s3 sync s3://${SOURCE_BUCKET_NAME}/${SOURCE_BUCKET_PATH} s3://${DEST_BUCKET_NAME} --delete
    env:
      SOURCE_BUCKET_NAME: ${{ secrets.AWS_S3_RELEASE_BUCKET }}
      SOURCE_BUCKET_PATH: ${{ steps.variables.outputs.SOURCE_PATH }}
      DEST_BUCKET_NAME: ${{ steps.variables.outputs.DEPLOY_BUCKET }}

  - name: 'Deployment success'
    if: success()
    uses: 'deliverybot/deployment-status@master'
    with:
      state: 'success'
      token: '${{ github.token }}'

  - name: 'Deployment failure'
    if: failure()
    uses: 'deliverybot/deployment-status@master'
    with:
      state: 'failure'
      token: '${{ github.token }}'
  1. Workflows/mail.yml

    name: Virtual Combine App UI

on: push: branches: - 'release/' - 'hotfix/'

jobs: lint_test: name: Affected Lint & Test runs-on: ubuntu-latest steps: - name: Copy Repo Files uses: actions/checkout@v1

  - name: Yarn Install
    uses: bahmutov/npm-install@v1
    with:
      useLockFile: true

  - name: Setup Env Files
    run: |
      touch src/config/env-urls.js
      echo "$ENV_URL_FILE" > src/config/env-urls.js
    env:
      ENV_URL_FILE: ${{ secrets.ALPHA_URL_FILE }}

  - name: Lint Affected
    run: yarn lint

  - name: Test Affected
    run: yarn test

build_staging: name: Build Staging needs: - lint_test

runs-on: ubuntu-latest
steps:
  - name: Copy Repo Files
    uses: actions/checkout@v1

  - name: Yarn Install
    uses: bahmutov/npm-install@v1
    with:
      useLockFile: true

  - name: Setup Env Files
    run: |
      touch src/config/env-urls.js
      echo "$ENV_URL_FILE" > src/config/env-urls.js
    env:
      ENV_URL_FILE: ${{ secrets.ALPHA_URL_FILE }}

  - name: Set Version
    id: version
    run: |
      if [ "$EVENT" == "push" ]; then
        export COMMIT="$(sed -e 's/^\(.\{9\}\).*/\1/' <<< "$SHA")"
      else
        export COMMIT="$(sed -e 's/^\(.\{9\}\).*/\1/' <<< "$PR_SHA")"
      fi
      export VERSION="$(node -pe "require('./package.json').version")"
      echo ::set-output name=COMMIT::$COMMIT
      echo ::set-output name=VERSION::$VERSION
      echo ::set-output name=DEST_DIR::$VERSION/$COMMIT/staging
    env:
      EVENT: ${{ github.event_name }}
      SHA: ${{ github.sha }}
      PR_SHA: ${{ github.event.pull_request.head.sha }}

  - name: Build
    run: yarn build
    env:
      DEPLOY_COMMIT: ${{ steps.version.outputs.COMMIT }}

  - name: Create Version File
    run: |
      echo "$VERSION/$COMMIT" > dist/apps/web/version.txt
    env:
      VERSION: ${{ steps.version.outputs.VERSION }}
      COMMIT: ${{ steps.version.outputs.COMMIT }}

  - name: Sync to S3
    uses: jakejarvis/s3-sync-action@master
    with:
      args: --quiet --delete
    env:
      AWS_S3_BUCKET: ${{ secrets.AWS_S3_RELEASE_BUCKET }}
      AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
      AWS_REGION: 'us-west-2'
      SOURCE_DIR: 'dist/apps/web'
      DEST_DIR: ${{ steps.version.outputs.DEST_DIR }}

build_production: name: Build Production needs: - lint_test

runs-on: ubuntu-latest
steps:
  - name: Copy Repo Files
    uses: actions/checkout@v1

  - name: Yarn Install
    uses: bahmutov/npm-install@v1
    with:
      useLockFile: true

  - name: Setup Env Files
    run: |
      touch src/config/env-urls.js
      echo "$ENV_URL_FILE" > src/config/env-urls.js
    env:
      ENV_URL_FILE: ${{ secrets.PROD_URL_FILE }}

  - name: Set Version
    id: version
    run: |
      if [ "$EVENT" == "push" ]; then
        export COMMIT="$(sed -e 's/^\(.\{9\}\).*/\1/' <<< "$SHA")"
      else
        export COMMIT="$(sed -e 's/^\(.\{9\}\).*/\1/' <<< "$PR_SHA")"
      fi
      export VERSION="$(node -pe "require('./package.json').version")"
      echo ::set-output name=VERSION::$VERSION
      echo ::set-output name=COMMIT::$COMMIT
      echo ::set-output name=DEST_DIR::$VERSION/$COMMIT/production
    env:
      EVENT: ${{ github.event_name }}
      SHA: ${{ github.sha }}
      PR_SHA: ${{ github.event.pull_request.head.sha }}

  - name: Build
    run: yarn build
    env:
      DEPLOY_COMMIT: ${{ steps.version.outputs.COMMIT }}

  - name: Create Version File
    run: |
      echo "$VERSION/$COMMIT" > dist/apps/web/version.txt
    env:
      VERSION: ${{ steps.version.outputs.VERSION }}
      COMMIT: ${{ steps.version.outputs.COMMIT }}

  - name: Sync to S3
    uses: jakejarvis/s3-sync-action@master
    with:
      args: --quiet --delete
    env:
      AWS_S3_BUCKET: ${{ secrets.AWS_S3_RELEASE_BUCKET }}
      AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
      AWS_REGION: 'us-west-2'
      SOURCE_DIR: 'dist/apps/web'
      DEST_DIR: ${{ steps.version.outputs.DEST_DIR }}
  1. deploy.yml

    staging: environment: staging production_environment: true

production: environment: production production_environment: true

0

There are 0 answers