generated from agendrix/terraform-aws-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
49 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,65 +2,51 @@ name: Release | |
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
env: | ||
UPLOAD_LAMBDA: false | ||
types: [prereleased, edited, released] | ||
|
||
jobs: | ||
# test: | ||
# name: Test lambda function | ||
# runs-on: ubuntu-latest | ||
|
||
# steps: | ||
# - uses: actions/checkout@v2 | ||
|
||
# - name: Install dependencies | ||
# run: yarn install | ||
|
||
# - name: Test | ||
# run: yarn test | ||
|
||
build-and-upload: | ||
name: Build GitHub action and AWS lambda function | ||
if: "false" # To be removed | ||
build: | ||
name: Build AWS lambda function | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: "main" | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Build lambda distribution | ||
run: yarn dist | ||
|
||
- 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: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Upload new build to AWS lambda | ||
- name: Get release tag | ||
id: ref | ||
run: | | ||
aws lambda update-function-code --function-name "$FUNCTION_ARN" --zip-file "fileb://$(pwd)/out/lambda.zip" | ||
TAG=${REF#"$PREFIX"} | ||
echo "::set-output name=tag::$TAG" | ||
env: | ||
FUNCTION_ARN: ${{ secrets.LAMBDA_FUNCTION_ARN }} | ||
REF: ${{ github.ref }} | ||
PREFIX: "refs/tags/" | ||
|
||
test-new-version: | ||
name: Test uploaded lambda | ||
needs: build-and-upload | ||
if: "false" # To be removed | ||
runs-on: ubuntu-latest | ||
- name: Update package.json version | ||
run: | | ||
tmp=$(mktemp) | ||
jq '.version = "${{ steps.ref.outputs.tag }}"' package.json > "$tmp" | ||
mv "$tmp" package.json | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Build lambda distribution | ||
run: yarn dist | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
- name: Setup GitHub git user | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
- name: Integration tests | ||
run: yarn test | ||
env: | ||
LAMBDA_URL: ${{ secrets.LAMBDA_URL }} | ||
- name: Push builds | ||
run: | | ||
git add package.json terraform/lambda.zip | ||
git commit -m "Build app for release ${{ steps.ref.outputs.tag }}" | ||
git push | ||
- name: Move release tag to latest commit | ||
run: | | ||
git tag --force "${{ steps.ref.outputs.tag }}" $(git rev-parse HEAD) | ||
git push --force --tags |
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