From ba49ccdeb98063707c0d2fd7173f006c539ac5e0 Mon Sep 17 00:00:00 2001 From: harold Date: Sun, 28 Nov 2021 19:20:29 -0500 Subject: [PATCH 1/2] Add GitHub Workflow Example --- .github/workflows/ci.yml | 67 ++++++++++++++++++++++++++++++++++++++++ README.md | 5 +-- requirements-dev.txt | 2 ++ 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 requirements-dev.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0524c7f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,67 @@ +name: CI Build + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +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 From 50272c2cf33262d1ceb3778fefbb98e2073b36ec Mon Sep 17 00:00:00 2001 From: harold Date: Mon, 29 Nov 2021 09:30:03 -0500 Subject: [PATCH 2/2] Default to manual invoke only --- .github/workflows/ci.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0524c7f..67031eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,14 @@ name: CI Build on: - push: - branches: [ main ] - pull_request: - branches: [ main ] + # 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 }}