diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..67031eb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,71 @@ +name: CI Build + +on: + # To enable build on push to main or pr to main, uncomment below + # push: + # branches: [ main ] + # pull_request: + # branches: [ main ] + + # Allow invocation of this workflow through the GitHub.com UI + workflow_dispatch: {} + +env: + PR_NUMBER: ${{ github.event.pull_request.number }} + NODE_ENV: production + DISABLE_OPENCOLLECTIVE: true + SAM_CLI_TELEMETRY: 0 + AWS_REGION: us-east-2 + SAM_BUCKET: '' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Use Node.js 14 + uses: actions/setup-node@v2 + with: + node-version: 14 + cache: 'npm' + cache-dependency-path: '**/package-lock.json' + + - name: Use Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Install awscli + run: | + pip3 install aws-sam-cli --upgrade --user + + - name: Install Node Modules + run: npm ci + env: + NODE_ENV: development + + - name: Audit Node Modules + run: npm audit --audit-level=moderate + + - name: Install Node Modules + run: npm run lint + + - name: Build + run: npm run build + + # To deploy to AWS: + # Set SAM_BUCKET to your S3 Bucket for SAM artifacts + # Set org-level or repo-level secrets: + # AWS_ACCESS_KEY_ID + # AWS_SECRET_ACCESS_KEY + # Attaching the following policies to the user / role used by this + # workflow would be sufficient, but also overly broad: + # - AWSLambda_FullAccess + # - AmazonS3FullAccess + - if: ${{ env.SAM_BUCKET != '' && github.event_name == 'push' && github.ref == 'refs/heads/main' }} + name: Deploy + run: npm run deploy + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} diff --git a/README.md b/README.md index 4582e17..c77f378 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # Sharp for AWS Lambda (with HEIC support) AWS Lambda Layer providing [sharp](https://github.com/lovell/sharp) with HEIC (and WebP) support -![Build Status](https://codebuild.us-east-1.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiKzJabytWb002SWpGcnVPMFp2K2VIZVR3QTZkYkx5L1gyZmFyV281emxnNzRFeklPdWF6ZDdBVllBczA4MVFxdDhpZnBaMnNneFk5WWx4Y3ZxUkplejIwPSIsIml2UGFyYW1ldGVyU3BlYyI6IkJKYlVqRVNSQlk2am5rUmwiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=main) +![CodeBuild Build Status](https://codebuild.us-east-1.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiKzJabytWb002SWpGcnVPMFp2K2VIZVR3QTZkYkx5L1gyZmFyV281emxnNzRFeklPdWF6ZDdBVllBczA4MVFxdDhpZnBaMnNneFk5WWx4Y3ZxUkplejIwPSIsIml2UGFyYW1ldGVyU3BlYyI6IkJKYlVqRVNSQlk2am5rUmwiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=main) +![GitHub Actions Build Status](https://github.com/zoellner/sharp-heic-lambda-layer/workflows/CI%20Build/badge.svg) ## Prerequisites @@ -14,7 +15,7 @@ Due to potential license concerns for the HEVC patent group, this repo can't be But you can compile and deploy this lambda layer yourself at your own risk and use it wihin your own accounts. All you need is an S3 bucket to deploy the compiled code to (replace `your-s3-bucket` in the code snippet below). Please see the note below regarding the build process. -It is recommended to automate this process using AWS CodeBuild. A buildspec file is provided in the repo. In that case you'll have to set the `SAM_BUCKET` environment variable in CodeBuild. For other environment variables see the table below. +It is recommended to automate this process using AWS CodeBuild or GitHub Actions. A `buildspec.yaml` file is provided as an example for CodeBuild and `.github/workflows/ci.yml` is provided as an example for GitHub Actions. In that case you'll have to set the `SAM_BUCKET` environment variable in CodeBuild. For other environment variables see the table below. ```bash npm run build diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..5d18c68 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,2 @@ +###### Requirements without Version Specifiers ###### +aws-sam-cli