ci: add a cloudwatch rule to keep the lambda warm #43
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Build & Deploy | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
AWS_REGION: eu-west-1 | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
if: github.repository == 'xtdb/xt-fiddle' | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- 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: ${{ env.AWS_REGION }} | |
- name: Prepare java | |
uses: actions/setup-java@v4.2.1 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- name: Setup Clojure | |
uses: DeLaGuardo/setup-clojure@12.5 | |
with: | |
cli: 1.11.3.1463 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '22' | |
cache: 'yarn' | |
- name: Install yarn deps | |
run: yarn install --frozen-lockfile | |
- name: Cache clojure dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.m2/repository | |
~/.gitlibs | |
~/.deps.clj | |
key: cljdeps-${{ hashFiles('deps.edn') }} | |
# key: cljdeps-${{ hashFiles('deps.edn', 'bb.edn') }} | |
restore-keys: cljdeps- | |
- name: Build jar | |
run: clojure -T:build jar | |
- name: upload to s3 | |
id: upload | |
run: | | |
mv target/lib-*.jar xt-play.jar | |
version=$(aws s3api put-object --body xt-play.jar --bucket xt-play-lambda-code --key xt-play.jar --output text --query VersionId) | |
echo "version=${version}" >> $GITHUB_OUTPUT | |
- name: Deploy to AWS CloudFormation | |
uses: aws-actions/aws-cloudformation-github-deploy@v1 | |
with: | |
name: 'xt-play--lambda' | |
template: cloudformation/03-lambda.yml | |
parameter-overrides: "PlayCodeVersion=${{ steps.upload.outputs.version }}" |