Using semantic-release with AWS CodePipeline and CodeBuild

Here is the usual pattern of getting the source from a git repository in AWS CodePipeline.

In the pipeline, we use AWS CodeStart to connect to a repo and get the source. Then, we pass it to the other stages, like deploy or publish.

For some unknown reasons, CodePipeline downloads the source as a zip from the repo instead of doing a git clone. This means the resource has no git meta data. Therefore, it doesn’t work with semantic-release (which requires it to be run in a git repository).

Hence, you will see this error below if you are trying to run npx semantic-release in a downstream CodeBuild job.

The semantic-release command must be executed from a Git repository. 
...
Please verify your CI configuration to make sure the semantic-release command is executed from the root of the cloned repository.

The easiest approach is to use git clone in the publish job where you are calling the semantic-release command.

Here is an example that uses Bitbucket. It works with any git repo. By setting the environment variable GIT_CREDENTIALS, the semantic release can also use it for versioning and change-logging.

export BITBUCKET_USER=yourusername
export BB_TOKEN=yourpassword
export GIT_CREDENTIALS=$BITBUCKET_USER:$BB_TOKEN
git clone https://$GIT_CREDENTIALS@bitbucket.org/user/repo.git
npx semantic-release --no-ci

Alternatively, you can copy and paste .git (the folder containing the git repo metadata) into the source from the early CodePipeline step. That’s fine, too.

Git
How to specify which Node version to use in Github Actions

When you want to specify which Node version to use in your Github Actions, you can use actions/setup-node@v2. The alternative way is to use a node container. When you try to use a publicly available node container like runs-on: node:alpine-xx, the pipeline gets stuck in a queue. runs-on is not …

DBA
mysqldump Error: Unknown table ‘COLUMN_STATISTICS’ in information_schema (1109)

mysqldump 8 enabled a new flag called columm-statistics by default. When you have MySQL client above 8 and try to run mysqldump on older MySQL versions, you will get the error below. mysqldump: Couldn’t execute ‘SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM ‘$”number-of-buckets-specified”‘) FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = ‘myschema’ AND TABLE_NAME = ‘craue_config_setting’;’: Unknown …

AWS
What You Need To Know About SAM Templates

AWS SAM template is a thin abstraction of a CloudFormation template to develop and deploy lambda by a AWS tool, SAM (Serverless Application Model). It has shorter syntax compared to writing infrastructure as code with CloudFormation. We still do a little bit of learning when it comes to writing SAM …