Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3 from fishbrain/create-release-workflow
Browse files Browse the repository at this point in the history
Add release action
  • Loading branch information
evdokimovn authored Aug 16, 2021
2 parents 84cfcea + e8b58e2 commit 5c8367a
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 11 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Create release
on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest
env:
DIST_OUTPUT_BUCKET: fishbrain-lambda-deploy
REGION: eu-west-1
SOLUTION_NAME: serverless-image-handler
VERSION: v5.2.1-meta
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install cdk
run: npm install -g aws-cdk
- name: Build
run: |
cd deployment
chmod +x ./build-s3-dist.sh
./build-s3-dist.sh ${{ env.DIST_OUTPUT_BUCKET }} ${{ env.SOLUTION_NAME }} ${{ env.VERSION }}
- name: Archive global assets
uses: papeloto/action-zip@v1
with:
files: deployment/global-s3-assets
dest: global-s3-assets.zip
- name: Archive regional assets
uses: papeloto/action-zip@v1
with:
files: deployment/regional-s3-assets
dest: regional-s3-assets.zip
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
regional-s3-assets.zip
global-s3-assets.zip
10 changes: 8 additions & 2 deletions source/constructs/lib/constructs-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

import * as cdk from '@aws-cdk/core';
import { ServerlessImageHandler, ServerlessImageHandlerProps } from './serverless-image-handler';
import { CfnParameter } from '@aws-cdk/core';
import {CfnParameter} from '@aws-cdk/core';
import {ServerlessImageHandler, ServerlessImageHandlerProps} from './serverless-image-handler';

const { VERSION } = process.env;

Expand All @@ -12,8 +12,10 @@ const { VERSION } = process.env;
*/
export class ConstructsStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
console.log('HELLO')
super(scope, id, props);

console.log('HELLO')
// CFN parameters
const corsEnabledParameter = new CfnParameter(this, 'CorsEnabled', {
type: 'String',
Expand Down Expand Up @@ -180,5 +182,9 @@ export class ConstructsStack extends cdk.Stack {
value: cdk.Fn.ref('LogRetentionPeriod'),
description: 'Number of days for event logs from Lambda to be retained in CloudWatch.'
}).overrideLogicalId('LogRetentionPeriod');
new cdk.CfnOutput(this, 'ImageHandlerApiOutput', {
value: cdk.Fn.ref('ImageHandlerApi'),
description: 'API Gateway Origin'
}).overrideLogicalId('ImageHandlerApi');
}
}
11 changes: 6 additions & 5 deletions source/constructs/lib/serverless-image-handler.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { Construct, CfnParameter } from "@aws-cdk/core";
import * as cdk from "@aws-cdk/core";
import {CfnParameter, Construct} from "@aws-cdk/core";
import * as cdkLambda from '@aws-cdk/aws-lambda';
import * as cdkS3 from '@aws-cdk/aws-s3';
import * as cdkIam from '@aws-cdk/aws-iam';
import * as cdk from '@aws-cdk/core';
import * as cdkCloudFront from '@aws-cdk/aws-cloudfront';
import * as cdkApiGateway from '@aws-cdk/aws-apigateway';
import * as cdkLogs from '@aws-cdk/aws-logs';
import { CloudFrontToApiGatewayToLambda } from '@aws-solutions-constructs/aws-cloudfront-apigateway-lambda';
import { CloudFrontToS3 } from '@aws-solutions-constructs/aws-cloudfront-s3';
import {CloudFrontToApiGatewayToLambda} from '@aws-solutions-constructs/aws-cloudfront-apigateway-lambda';
import {CloudFrontToS3} from '@aws-solutions-constructs/aws-cloudfront-s3';
import apiBody from './api.json';

const { BUCKET_NAME, SOLUTION_NAME, VERSION } = process.env;
Expand Down Expand Up @@ -138,7 +138,8 @@ export class ServerlessImageHandler extends Construct {
new cdkIam.PolicyStatement({
actions: [
'rekognition:DetectFaces',
'rekognition:DetectModerationLabels'
'rekognition:DetectModerationLabels',
'rekognition:DetectLabels'
],
resources: [
'*'
Expand Down
6 changes: 3 additions & 3 deletions source/constructs/test/constructs.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { expect as expectCDK, matchTemplate, MatchStyle } from '@aws-cdk/assert';
import {expect as expectCDK, MatchStyle, matchTemplate} from '@aws-cdk/assert';
import * as cdk from '@aws-cdk/core';
import * as Constructs from '../lib/constructs-stack';
import {ConstructsStack} from '../lib/constructs-stack';
import TestTemplate from './serverless-image-handler-test.json';

test('Serverless Image Handler Stack', () => {
const app = new cdk.App();
// WHEN
const stack = new Constructs.ConstructsStack(app, 'MyTestStack');
const stack = new ConstructsStack(app, 'MyTestStack');
// THEN
expectCDK(stack).to(matchTemplate(TestTemplate, MatchStyle.EXACT));
});
9 changes: 8 additions & 1 deletion source/constructs/test/serverless-image-handler-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@
{
"Action": [
"rekognition:DetectFaces",
"rekognition:DetectModerationLabels"
"rekognition:DetectModerationLabels",
"rekognition:DetectLabels"
],
"Effect": "Allow",
"Resource": "*"
Expand Down Expand Up @@ -1755,6 +1756,12 @@
"Value": {
"Ref": "LogRetentionPeriod"
}
},
"ImageHandlerApi": {
"Description": "API Gateway Origin",
"Value": {
"Ref": "ImageHandlerApi"
}
}
}
}

0 comments on commit 5c8367a

Please sign in to comment.