Merge pull request #83 from aligent/hotfix/Add-Inputs-S3-Upload #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: S3 Deployment | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| aws-region: | ||
| description: "AWS region" | ||
| type: string | ||
| required: false | ||
| default: "ap-southeast-2" | ||
| s3-bucket: | ||
| description: "Name of the S3 bucket" | ||
| type: string | ||
| required: true | ||
| s3-path: | ||
| description: "Path in the S3 bucket" | ||
| type: string | ||
| required: false | ||
| default: "" | ||
| local-path: | ||
| description: "Path to deploy" | ||
| type: string | ||
| required: true | ||
| default: "" | ||
| delete-flag: | ||
| description: "Enable --delete flag" | ||
| type: boolean | ||
| required: false | ||
| default: true | ||
| cache-control: | ||
| description: "Cache control headers" | ||
| type: string | ||
| required: false | ||
| extra-args: | ||
| description: "Additional AWS CLI args" | ||
| type: string | ||
| required: false | ||
| default: "" | ||
| aws-access-key-id: | ||
| description: "AWS Access Key ID" | ||
| type: string | ||
| required: true | ||
| secrets: | ||
| aws-secret-access-key: | ||
| description: "AWS Secret Access Key" | ||
| type: string | ||
| required: true | ||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Configure AWS creds | ||
| uses: aws-actions/configure-aws-credentials@latest | ||
| with: | ||
| aws-access-key-id: ${{ inputs.aws-access-key-id }} | ||
| aws-secret-access-key: ${{ secrets.aws-secret-access-key }} | ||
| aws-region: ${{ inputs.aws-region }} | ||
| - name: Deploy to S3 | ||
| run: | | ||
| s3_path="" | ||
| cache_control="" | ||
| extra_args="" | ||
| if [ -n "${{inputs.cache-control}}" ]; then | ||
| cache_control="--cache-control \"${{inputs.cache-control}}\"" | ||
| fi | ||
| command="aws s3 sync ${{inputs.local-path}} s3://${{inputs.s3-bucket}}${{inputs.s3-path}} ${cache_control} ${{inputs.extra-args}}" | ||
| if [ "${{inputs.delete-flag}}" = "true" ]; then | ||
| command="$command --delete" | ||
| fi | ||
| $command | ||