Skip to content

Commit f471ed3

Browse files
authored
ci: Adding GitHub Action s3 sync mechanism for internal repository (#7)
Adding GitHub Action s3 sync mechanism for internal repository
1 parent 25ea211 commit f471ed3

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Upload Build to S3
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
env:
7+
BUCKET_NAME : "${{ secrets.S3_BUCKET_NAME }}"
8+
AWS_REGION : "us-west-2"
9+
10+
# permission can be added at job level or workflow level
11+
permissions:
12+
id-token: write # This is required for requesting the JWT
13+
contents: read # This is required for actions/checkout
14+
15+
jobs:
16+
on-success:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
python-version: ["3.13"]
22+
23+
steps:
24+
- uses: actions/checkout@v5
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v6
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
- name: Install Hatch
30+
run: |
31+
python -m pip install --upgrade hatch
32+
- name: Build distribution
33+
run: hatch build
34+
- name: configure aws credentials
35+
uses: aws-actions/configure-aws-credentials@v4
36+
with:
37+
role-to-assume: "${{ secrets.ACTIONS_SYNC_ROLE_NAME }}"
38+
role-session-name: gh-python
39+
aws-region: ${{ env.AWS_REGION }}
40+
- name: Copy tar gz build file to s3
41+
run: |
42+
aws s3 cp ./dist/aws_durable_execution_sdk_python-0.0.1.tar.gz \
43+
s3://${{ env.BUCKET_NAME }}/
44+
- name: commit tar gz to Gitfarm
45+
run: |
46+
aws lambda invoke \
47+
--function-name ${{ secrets.SYNC_LAMBDA_ARN }} \
48+
--payload '{"gitFarmRepo":"${{ secrets.GITFARM_LAN_SDK_REPO }}","gitFarmBranch":"${{ secrets.GITFARM_LAN_SDK_BRANCH }}","gitFarmFilepath":"aws_durable_execution_sdk_python-0.0.1.tar.gz","s3Bucket":"${{ secrets.S3_BUCKET_NAME }}","s3FilePath":"aws_durable_execution_sdk_python-0.0.1.tar.gz"}' \
49+
--cli-binary-format raw-in-base64-out \
50+
output.txt
51+
- name: Check for error in lambda invoke
52+
id: check_text_tar_gz
53+
run: |
54+
if grep -q "Error" output.txt; then
55+
cat output.txt
56+
exit 1
57+
fi

0 commit comments

Comments
 (0)