From 373c0630ae68d4f3b7a2ed7c48a5f4c31ca4ea29 Mon Sep 17 00:00:00 2001 From: Gabriel Suquet <91719818+gsuquet@users.noreply.github.com> Date: Wed, 13 Dec 2023 14:59:07 +0100 Subject: [PATCH] :sparkles: feat: Add workflow to upload files to AWS S3 (#10) # Description Add a reusable workflow to copy files to an AWS S3 bucket ## Type of change :sparkles: New feature (non-breaking change which adds functionality) # Checklist: - [X] My code follows the style guidelines of this project - [X] I have performed a self-review of my own code - [X] I have made corresponding changes to the documentation - [X] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [X] Any dependent changes have been merged and published in downstream modules --------- Co-authored-by: GitHub Action <41898282+github-actions[bot]@users.noreply.github.com> --- .github/workflows/deployment-s3.yml | 50 +++++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 51 insertions(+) create mode 100644 .github/workflows/deployment-s3.yml diff --git a/.github/workflows/deployment-s3.yml b/.github/workflows/deployment-s3.yml new file mode 100644 index 0000000..e9e86ed --- /dev/null +++ b/.github/workflows/deployment-s3.yml @@ -0,0 +1,50 @@ +name: Upload files to AWS S3 +on: + workflow_call: + inputs: + aws_region: + description: 'AWS region' + required: false + type: string + default: eu-west-1 + files_path: + description: 'The path to the files to copy' + required: false + type: string + default: . + artifact_name: + description: 'The name of the artifact to download' + required: false + type: string + secrets: + bucket_path: + required: true + description: The path to the S3 bucket to copy files to + aws_access_key_id: + required: true + description: The AWS access key ID + aws_secret_access_key: + required: true + description: The AWS secret access key + +jobs: + upload: + runs-on: ubuntu-latest + steps: + - name: Download artifacts + if: ${{ inputs.artifact_name }} + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.artifact_name }} + path: ${{ inputs.files_path }} + + - name: Copy files to S3 + env: + AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }} + run: | + aws s3 cp \ + --recursive \ + --region ${{ inputs.aws_region }} \ + ${{ inputs.files_path }} \ + s3://${{ secrets.bucket_path }} diff --git a/README.md b/README.md index bd7fcc5..ee5cdb1 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ jobs: | automation | [comment-pr](./.github/workflows/automation-comment-pr.yml) | Add or update a comment on the pull request | | automation | [greeter](./.github/workflows/automation-greeter.yml) | Greetings | | automation | [labeler](./.github/workflows/automation-labeler.yml) | Labeler | +| deployment | [s3](./.github/workflows/deployment-s3.yml) | Upload files to AWS S3 | | integration | [commit-validator](./.github/workflows/integration-commit-validator.yml) | Validate commit or PR title format is correct | | integration | [linter-pre-commit](./.github/workflows/integration-linter-pre-commit.yml) | Pre-commit | | integration | [modification-script](./.github/workflows/integration-modification-script.yml) | Execute script and commit changes to git |