Skip to content

Commit 43ae4fe

Browse files
SilanHehsilan
andauthored
chore: Gitfarm sync (#16)
sync sdk and sdk testing internally --------- Co-authored-by: hsilan <hsilan@amazon.com>
1 parent fe12ac7 commit 43ae4fe

3 files changed

Lines changed: 131 additions & 0 deletions

File tree

.github/workflows/sync-package.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Sync package
2+
3+
env:
4+
AWS_REGION: "us-west-2"
5+
6+
# permission can be added at job level or workflow level
7+
permissions:
8+
id-token: write # This is required for requesting the JWT
9+
contents: read # This is required for actions/checkout
10+
11+
on:
12+
workflow_call:
13+
inputs:
14+
module_name:
15+
required: true
16+
type: string
17+
package_name:
18+
required: true
19+
type: string
20+
secrets:
21+
S3_BUCKET_NAME:
22+
required: true
23+
SYNC_LAMBDA_ARN:
24+
required: true
25+
GITFARM_LAN_SDK_REPO:
26+
required: true
27+
GITFARM_LAN_SDK_BRANCH:
28+
required: true
29+
ACTIONS_SYNC_ROLE_NAME:
30+
required: true
31+
jobs:
32+
upload-to-S3-and-sync-to-Gitfarm:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Git clone the repository
36+
uses: actions/checkout@v5
37+
- name: Set up JDK 17
38+
uses: actions/setup-java@v4
39+
with:
40+
java-version: '17'
41+
distribution: 'temurin'
42+
cache: maven
43+
- name: Get version
44+
id: get_version
45+
run: |
46+
VERSION=$( mvn -f ${{ inputs.module_name }}/pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout )
47+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
48+
- name: Show extracted Maven project version
49+
run: echo ${{ steps.get_version.outputs.version }}
50+
- name: Build with Maven
51+
run: mvn -B package --file pom.xml
52+
- name: configure aws credentials
53+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
54+
with:
55+
role-to-assume: "${{ secrets.ACTIONS_SYNC_ROLE_NAME }}"
56+
role-session-name: samplerolesession
57+
aws-region: ${{ env.AWS_REGION }}
58+
# Upload a file to AWS s3
59+
- name: Copy tgz build file to s3
60+
run: |
61+
aws s3 cp ./${{ inputs.module_name }}/target/${{ inputs.package_name }}-${{ steps.get_version.outputs.version }}.jar \
62+
s3://${{ secrets.S3_BUCKET_NAME }}/${{ inputs.package_name }}.jar
63+
- name: commit to Gitfarm
64+
run: |
65+
aws lambda invoke \
66+
--function-name ${{ secrets.SYNC_LAMBDA_ARN }} \
67+
--payload '{"gitFarmRepo":"${{ secrets.GITFARM_LAN_SDK_REPO }}","gitFarmBranch":"${{ secrets.GITFARM_LAN_SDK_BRANCH }}","gitFarmFilepath":"${{ secrets.GITFARM_LAN_SDK_REPO }}-1.0.jar","s3Bucket":"${{ secrets.S3_BUCKET_NAME }}","s3FilePath":"${{ inputs.package_name }}.jar", "gitHubRepo": "aws-durable-execution-sdk-java", "gitHubCommit":"${{ github.sha }}"}' \
68+
--cli-binary-format raw-in-base64-out \
69+
output.txt
70+
- name: Check for specific text in a file
71+
id: check_text
72+
run: |
73+
if grep -q "Error" output.txt; then
74+
cat output.txt
75+
exit 1
76+
fi

.github/workflows/sync-sdk.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Sync SDK
2+
on:
3+
push:
4+
branches: ["main"]
5+
paths:
6+
- "sdk/**"
7+
8+
env:
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+
sync-aws-durable-execution-sdk-java:
18+
uses: ./.github/workflows/sync-package.yml
19+
with:
20+
module_name: sdk
21+
package_name: aws-durable-execution-sdk-java
22+
secrets:
23+
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
24+
SYNC_LAMBDA_ARN: ${{ secrets.SYNC_LAMBDA_ARN }}
25+
GITFARM_LAN_SDK_REPO: ${{ secrets.GITFARM_LAN_SDK_REPO }}
26+
GITFARM_LAN_SDK_BRANCH: ${{ secrets.GITFARM_LAN_SDK_BRANCH }}
27+
ACTIONS_SYNC_ROLE_NAME: ${{ secrets.ACTIONS_SYNC_ROLE_NAME }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Sync Testing SDK
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
paths:
7+
- "sdk-testing/**"
8+
9+
env:
10+
AWS_REGION: "us-west-2"
11+
12+
# permission can be added at job level or workflow level
13+
permissions:
14+
id-token: write # This is required for requesting the JWT
15+
contents: read # This is required for actions/checkout
16+
17+
jobs:
18+
sync-aws-durable-execution-sdk-java-testing:
19+
uses: ./.github/workflows/sync-package.yml
20+
with:
21+
module_name: sdk-testing
22+
package_name: aws-durable-execution-sdk-java-testing
23+
secrets:
24+
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
25+
SYNC_LAMBDA_ARN: ${{ secrets.SYNC_LAMBDA_ARN }}
26+
GITFARM_LAN_SDK_REPO: ${{ secrets.GITFARM_TESTING_SDK_REPO }}
27+
GITFARM_LAN_SDK_BRANCH: ${{ secrets.GITFARM_LAN_SDK_BRANCH }}
28+
ACTIONS_SYNC_ROLE_NAME: ${{ secrets.ACTIONS_SYNC_ROLE_NAME }}

0 commit comments

Comments
 (0)