|
| 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 |
0 commit comments