Skip to content

Add action to upload S3 assets #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,29 @@ working directory.
uses: mongodb-labs/drivers-github-tools/code-scanning-export@v2
```

## Upload S3 assets

A number of scripts create files in the `tmp/s3_assets` folder, which then can
be uploaded to the product's S3 bucket:

```yaml
- name: Setup
uses: mongodb-labs/drivers-github-tools/setup@v2
with:
...

- name: Upload S3 assets
uses: mongodb-labs/drivers-github-tools/upload-s3-assets@v2
with:
version: <release version>
product_name: <product_name>
```

Optionally, you can specify which files to upload using the `filenames` input.
By default, all files in the S3 directory are uploaded. When the `dry_run` input
is set to anything other than `false`, no files are uploaded, but instead the
filename along with the resulting location in the bucket is printed.

## Python Helper Scripts

These scripts are opinionated helper scripts for Python releases.
Expand Down
29 changes: 29 additions & 0 deletions upload-s3-assets/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Upload S3 assets
description: Uploads assets from the S3 asset directory
inputs:
version:
description: "The published version"
required: true
product_name:
description: "The name of the product"
required: true
filenames:
description: "Files to upload - supports wildcards and glob patterns"
default: '*'
required: false
dry_run:
description: "Only print files that would be uploaded, but don't upload any files"
required: false
default: 'false'

runs:
using: composite
steps:
- shell: bash
working-directory: ${{ env.S3_ASSETS }}
run: |
if [ "${{ inputs.dry_run }}" == "false" ]; then
for filename in ${{ inputs.filenames }}; do aws s3 cp ${filename} s3://${AWS_BUCKET}/${{ inputs.product_name }}/${{ inputs.version }}/${filename}; done
else
for filename in ${{ inputs.filenames }}; do echo "Would upload ${filename} to ${{ inputs.product_name }}/${{ inputs.version }}/${filename}"; done
fi
Loading