Skip to content

Commit f617f87

Browse files
authored
Create upload-build-to-s3.yml
1 parent 25ea211 commit f617f87

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Upload Build to S3
2+
3+
on:
4+
push:
5+
branches: [ "main"]
6+
7+
env:
8+
BUCKET_NAME : "${{ secrets.S3_BUCKET_NAME }}"
9+
AWS_REGION : "us-west-2"
10+
11+
# permission can be added at job level or workflow level
12+
permissions:
13+
id-token: write # This is required for requesting the JWT
14+
contents: read # This is required for actions/checkout
15+
16+
jobs:
17+
on-success:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Git clone the repository
21+
uses: actions/checkout@v5
22+
- name: Use Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
cache: 'npm'
27+
- name: configure aws credentials
28+
uses: aws-actions/configure-aws-credentials@v4
29+
with:
30+
role-to-assume: "${{ secrets.ACTIONS_SYNC_ROLE_NAME }}"
31+
role-session-name: samplerolesession
32+
aws-region: ${{ env.AWS_REGION }}
33+
- name: get-npm-version
34+
id: package-version
35+
uses: martinbeentjes/npm-get-version-action@v1.3.1
36+
with:
37+
path: packages/lambda-durable-functions-sdk-js
38+
# need this while workflow_run isn't working as expected
39+
- run: npm run install-all
40+
- run: npm run build
41+
#####
42+
- name: Navigate to package and pack
43+
working-directory: packages/lambda-durable-functions-sdk-js
44+
run: npm pack
45+
# Upload a file to AWS s3
46+
- name: Copy tgz build file to s3
47+
run: |
48+
aws s3 cp ./packages/lambda-durable-functions-sdk-js/amzn-durable-executions-language-sdk-${{ steps.package-version.outputs.current-version }}.tgz \
49+
s3://${{ env.BUCKET_NAME }}/
50+
- name: commit to Gitfarm
51+
run: |
52+
aws lambda invoke \
53+
--function-name ${{ secrets.SYNC_LAMBDA_ARN }} \
54+
--payload '{"gitFarmRepo":"${{ secrets.GITFARM_LAN_SDK_REPO }}","gitFarmBranch":"${{ secrets.GITFARM_LAN_SDK_BRANCH }}","gitFarmFilepath":"amzn-durable-executions-language-sdk-${{ steps.package-version.outputs.current-version }}.tgz","s3Bucket":"${{ secrets.S3_BUCKET_NAME }}","s3FilePath":"amzn-durable-executions-language-sdk-${{ steps.package-version.outputs.current-version }}.tgz"}' \
55+
--cli-binary-format raw-in-base64-out \
56+
output.txt
57+
- name: Check for specific text in a file
58+
id: check_text
59+
run: |
60+
if grep -q "Error" output.txt; then
61+
cat output.txt
62+
exit 1
63+
fi

0 commit comments

Comments
 (0)