Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release Please

on:
push:
branches:
- production

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}

build-artifact:
needs: release-please
if: ${{ needs.release-please.outputs.release_created }}
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22

- name: Install production dependencies
run: npm ci --omit=dev

- name: Create function.zip
run: zip -r function.zip . -x "*.git*" -x "terraform/*" -x ".github/*" -x "test/*" -x "*.md"

- name: Upload artifact to release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.release-please.outputs.tag_name }}
files: function.zip
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- dev
- production
pull_request:
branches:
- dev
- production

jobs:
test:
Expand Down
37 changes: 25 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,36 @@ More info: http://pm2.keymetrics.io/docs/usage/quick-start/

## Deploy to AWS Lambda

Install [Claudia.js](https://claudiajs.com/), then:
### Automated Deploy Pipeline
This service is deployed automatically through AWS CodePipeline. Updates to the development, staging, or production branches trigger the pipeline to fetch the latest code, build and test it, and deploy the resulting ZIP package to the Lambda function. Deployment start and completion notifications are sent to the Slack bots channel.

cd ~/code/github/pressbooks/pb-mathjax
claudia create --handler lambda.handler --deploy-proxy-api --region us-east-1 --timeout 15 --memory 256 --profile yourself --use-local-dependencies
For more details, see the Terraform directory.

### Releases and Versioning

This repository uses [Release Please](https://github.com/googleapis/release-please) to automate versioning and changelog generation. See the [CHANGELOG](CHANGELOG.md) for a history of changes.

Where `us-east-1` is your AWS region and `yourself` corresponds to an identity in your `~/.aws/credentials` file.
**How it works:**

If everything goes well, the above command will finish after a few moments and print a response with a URL. Use in Pressbooks as the value for `PB_MATHJAX_URL`
1. Write commits to the `production` branch using [Conventional Commits](https://www.conventionalcommits.org/) format:
- `feat: add new endpoint` - triggers a minor version bump
- `fix: resolve svg rendering issue` - triggers a patch version bump
- `feat!: change API response format` or `BREAKING CHANGE:` in body - triggers a major version bump

More info: https://claudiajs.com/tutorials/installing.html https://github.com/claudiajs/claudia/blob/master/docs/
2. Release Please automatically creates/updates a Release PR that includes:
- Version bump in `package.json`
- Auto-generated `CHANGELOG.md` entries

If you are deploying not for the first time, use
3. When you merge the Release PR:
- A GitHub Release is created with a version tag (e.g., `v1.2.0`)
- The merge triggers AWS CodePipeline to deploy to Lambda

**Example commit messages:**

```
rm -rf node_modules package-lock.json
npm install --arch=x64 --platform=linux
claudia update --use-local-dependencies
feat: add support for custom fonts
fix: handle edge case in base64 decoding
docs: update API documentation
chore: update dependencies
feat!: remove deprecated latex endpoint
```

This will download the dependencies needed for Linux and deploy to AWS Lambda.
10 changes: 0 additions & 10 deletions claudia.json

This file was deleted.

2 changes: 0 additions & 2 deletions src/imageGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,8 @@ module.exports.generate = async (configs, req, res, next) => {
scale: 1
});


let svgContent = adaptor.innerHTML(node);


if (!svgContent || !svgContent.includes('<svg') || !svgContent.includes('</svg>')) {
return handleError(res);
}
Expand Down