Skip to content

Commit

Permalink
feat: truncate and remove chars from version desc. before deploy (#65)
Browse files Browse the repository at this point in the history
* feat: truncate and remove chars from version desc. before deploy

Currently, we get the following error when we attempt to deploy to
AWS EB with certain commit messages:

```
Deployment failed: Error: Status: 403. Code: SignatureDoesNotMatch,
Message: The request signature we calculated does not match the
signature you provided. Check your AWS Secret Access Key and signing
method. Consult the service documentation for details.
```

This is not because our access key is wrong, but because there are
certain characters in our commit message which are not dealt with
properly by the beanstalk-deploy package. We know that the following
characters have produced problems for us:

```
( ) '
```

These are due to encoding issues on the original beanstalk-deploy
library.

Rather than wait for a fix from the package author, we can first
truncate the message, since the title is in the first few words,
to lower the chance of a special character, and then we can replace
these characters ourselves in the deploy step when setting the
version description.

* chore: set DEV_BRANCH to be staging-dev

Co-authored-by: Jie Hao Kwa <[email protected]>
  • Loading branch information
kwajiehao and Jie Hao Kwa authored Nov 4, 2020
1 parent 266f312 commit 7af66b4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ on:
env:
PRODUCTION_BRANCH: refs/heads/master
STAGING_BRANCH: refs/heads/staging
DEV_BRANCH: refs/heads/setup-github-actions
DEV_BRANCH: refs/heads/staging-dev
EB_APP: isomer-cms
EB_ENV_PRODUCTION: isomercms-backend-prod
EB_ENV_STAGING: isomercms-backend-staging
EB_ENV_DEV: isomercms-backend-staging-dev
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
jobs:
gatekeep:
name: Determine if Build & Deploy is needed
Expand Down Expand Up @@ -65,6 +66,14 @@ jobs:
id: get_label
env:
TIMESTAMP: ${{ steps.get_timestamp.outputs.timestamp }}
- name: Get truncated version_description
id: get_desc
shell: python
run: |
import os
commit_message = os.environ['COMMIT_MESSAGE']
description = commit_message[0:100].replace('(', '').replace(')', '').replace('\'', '')
print('::set-output name=desc::' + description)
- name: Select Elastic Beanstalk variables
shell: python
run: |
Expand Down Expand Up @@ -94,7 +103,7 @@ jobs:
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY_FOR_DEPLOYMENT }}
application_name: ${{ steps.select_eb_vars.outputs.eb_app }}
environment_name: ${{ steps.select_eb_vars.outputs.eb_env }}
version_description: ${{ github.event.head_commit.message }}
version_description: ${{ steps.get_desc.output.desc }}
version_label: ${{ steps.get_label.outputs.label }}
region: ap-southeast-1
deployment_package: deploy.zip
Expand Down

0 comments on commit 7af66b4

Please sign in to comment.