Skip to content

Commit

Permalink
feat: add composite action for validating a bucket URI
Browse files Browse the repository at this point in the history
  • Loading branch information
CallumNZ committed Oct 17, 2024
1 parent 12c9a58 commit 5454739
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/actions/validate-bucket-uri/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Validate S3 Bucket URI
description: Validates an AWS S3 bucket URI.
inputs:
s3-bucket-uri:
type: string
description: "The S3 bucket URI to validate"
required: true
runs:
using: "composite"
steps:
- name: Validate
shell: bash
env:
REGEXP: "^s3://[a-zA-Z0-9!_.*'()/-]+$"
S3_BUCKET_URI: ${{ inputs.s3-bucket-uri }}
run: |
if ! echo "$S3_BUCKET_URI" | grep -q -E $REGEXP; then
echo "error: not a valid S3 bucket URI '$S3_BUCKET_URI'" >/dev/stderr
exit 1
fi
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- [AWS deploy](#aws-deploy)
- [Composite Actions](#composite-actions)
- [Tagging](#tagging)
- [Validate bucket URI](#validate-bucket-uri)
- [Other documentation](#other-documentation)
- [Dependabot and Actions workflow imports](#dependabot-and-actions-workflow-imports)
- [Versioning for container images](#versioning-for-container-images)
Expand Down Expand Up @@ -1229,6 +1230,25 @@ jobs:
tag: ${{ needs.prepare.outputs.tag }}
```

### Validate bucket URI

STATUS: beta

Validate an S3 bucket URI by checking it is in the right format and contains only valid characters.

```yaml
on: [push]
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- name: Validate bucket
uses: GeoNet/Actions/.github/actions/validate-bucket-uri@main
with:
s3-bucket-uri: s3://my-bucket-to-validate/my-bucket-prefix
```

## Other documentation

### Dependabot and Actions workflow imports
Expand Down

0 comments on commit 5454739

Please sign in to comment.