Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-y-ito committed Nov 4, 2023
1 parent 317eb30 commit bb6159b
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 7 deletions.
68 changes: 67 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,67 @@
# gha-s3-deploy
# Deploy to AWS S3
Deploy a static website to AWS S3.

## Usage
1. Create a S3 bucket and enable static website hosting
2. Add a bucket policy to allow public read access to the bucket
3. Create a new IAM user with right permissions
4. Generate an access key for the user
5. Add the access key to your GitHub repository's secrets
6. Use this GitHub action by referencing the v1 branch:
```yaml
- uses: uskayyyyy/gha-s3-deploy@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
bucket-name: your-bucket-name
```
## Inputs
S3 Deploy's Action supports inputs from the user listed in the table below:
Input Type Required Default Description
| Input | Required | Default | Description |
| --------------------- | -------- | --------- | ----------------------------------------------------------- |
| aws-access-key-id | Yes | | AWS Access Key ID for authentication |
| aws-secret-access-key | Yes | | AWS Secret Access Key for authentication |
| bucket-name | Yes | | The S3 bucket where your website will be hosted |
| bucket-region | No | us-east-1 | The region of the S3 bucket |
| src-folder | No | . | Absolute path of the folder containing the deployable files |
## Outputs
This action provides the following outputs that can be accessed in subsequent steps of your workflow using the `steps` context.

| Output | Description |
| ------------- | ------------------------------------- |
| `website-url` | The URL of your website hosted on S3. |

## Example
```yaml
# .github/workflows/example.yml
name: Example workflow for S3 Deploy
on: push
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Deploy
id: deploy
uses: uskayyyyy/gha-s3-deploy@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
bucket-name: your-bucket-name
bucket-region: us-west-2 # Optional - Default: us-east-1
src-folder: ./dist # Optional - Default: . (root)
- name: Output Website URL
run: echo ${{ steps.deploy.outputs.website-url }}
```

## License
The code in this project is released under the MIT License.
11 changes: 5 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ inputs:
description: AWS Secret Access Key for authentication
required: true
bucket-name:
description: The S3 bucket name your website is going to be hosted to.
description: The name of the S3 bucket where your website will be hosted
required: true
bucket-region:
description: The region of the S3 bucket.
description: The region of the S3 bucket
required: false
default: us-east-1
src-folder:
description: Absolute path of the folder containing the deployable files.
description: Absolute path of the folder containing the deployable files
required: false
default: .
outputs:
Expand All @@ -34,9 +34,8 @@ runs:
aws configure set aws_secret_access_key ${{ inputs.aws-secret-access-key }}
- name: Sync S3
shell: bash
run: aws s3 sync ${{ inputs.src-folder }} s3://${{ inputs.bucket-name}} --region ${{ inputs.bucket-region }}
run: aws s3 sync ${{ inputs.src-folder }} s3://${{ inputs.bucket-name }} --region ${{ inputs.bucket-region }}
- name: Output URL
id: output-url
shell: bash
run: echo 'website-url="http://${{ inputs.bucket-name }}.s3-website-${{ inputs.bucket-region}}.amazonaws.com/"' >> $GITHUB_OUTPUT ';'

run: echo 'website-url="http://${{ inputs.bucket-name }}.s3-website-${{ inputs.bucket-region }}.amazonaws.com/"' >> $GITHUB_OUTPUT ';'

0 comments on commit bb6159b

Please sign in to comment.