{"id":16293553,"url":"https://github.com/badsyntax/github-action-aws-static-stack","last_synced_at":"2025-03-20T03:31:08.259Z","repository":{"id":37792588,"uuid":"437470408","full_name":"badsyntax/github-action-aws-static-stack","owner":"badsyntax","description":"A GitHub Action to deploy your static website to the AWS Edge.","archived":false,"fork":false,"pushed_at":"2023-10-02T19:20:17.000Z","size":310,"stargazers_count":3,"open_issues_count":5,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T14:22:06.298Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/badsyntax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-12T06:27:40.000Z","updated_at":"2023-12-11T21:19:41.000Z","dependencies_parsed_at":"2024-10-27T21:44:36.845Z","dependency_job_id":"7345785a-0f52-4c00-8cf9-2c9e64a6ad00","html_url":"https://github.com/badsyntax/github-action-aws-static-stack","commit_stats":{"total_commits":37,"total_committers":3,"mean_commits":"12.333333333333334","dds":0.05405405405405406,"last_synced_commit":"e4b7ea27cefe489428b9cd95b223f06f74b6ef0f"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badsyntax%2Fgithub-action-aws-static-stack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badsyntax%2Fgithub-action-aws-static-stack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badsyntax%2Fgithub-action-aws-static-stack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badsyntax%2Fgithub-action-aws-static-stack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/badsyntax","download_url":"https://codeload.github.com/badsyntax/github-action-aws-static-stack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244543778,"owners_count":20469562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T20:11:42.775Z","updated_at":"2025-03-20T03:31:07.829Z","avatar_url":"https://github.com/badsyntax.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS Static Stack GitHub Action\n\n[![Test](https://github.com/badsyntax/github-action-aws-static-stack/actions/workflows/test.yml/badge.svg)](https://github.com/badsyntax/github-action-aws-static-stack/actions/workflows/test.yml)\n[![Deploy](https://github.com/badsyntax/github-action-aws-static-stack/actions/workflows/deploy.yml/badge.svg)](https://github.com/badsyntax/github-action-aws-static-stack/actions/workflows/deploy.yml)\n\nA composite GitHub Action to deploy your static website to the AWS Edge.\n\nThis Action is _opinionated_ meaning it relies on a specific AWS configuration (managed by CloudFormation IaC). It's not likely everyone will agree with default stack configuration or workflows, but I've written the sub-Actions to be generic so you can use the sub-Actions to create your own static deploy pipeline if you require more flexibility. Refer to [`action.yaml`](https://github.com/badsyntax/github-action-aws-static-stack/blob/master/action.yml) for example usage of the various Actions.\n\n## Features\n\n- Preview sites with Pull Request comments\n- S3 for origin object storage\n- Cloudfront Edge caching\n- Separate Root \u0026 Preview Cloudfront distributions\n  - The Preview distribution uses a Lambda to rewrite the URLs to the correct location in the S3 origin\n  - The Root distribution routes directly to the S3 origin and does not use a Lambda, to provide the fastest possible response times\n- Flexible stack creation (you provide \u0026 own the IaC)\n\nThe following GitHub Actions are used:\n\n- [badsyntax/github-action-aws-cloudformation](https://github.com/badsyntax/github-action-aws-cloudformation)\n- [badsyntax/github-action-aws-cloudfront](https://github.com/badsyntax/github-action-aws-cloudfront)\n- [badsyntax/github-action-aws-s3](https://github.com/badsyntax/github-action-aws-s3)\n- [badsyntax/github-action-issue-comment](https://github.com/badsyntax/github-action-issue-comment)\n\n## Getting Started\n\nYou should be somewhat familiar with the following technologies:\n\n- AWS CloudFormation (Infrastructure as Code)\n- AWS S3 (Object storage)\n- AWS CloudFront (CDN \u0026 Edge Caching)\n- GitHub Actions (CI/CD)\n\nPlease also read the following to understand what AWS Credentials you should use: \u003chttps://github.com/aws-actions/configure-aws-credentials#credentials\u003e\n\n### Step 1: Define your Stack\n\nUse the [provided CloudFormation stack](https://github.com/badsyntax/github-action-aws-static-stack/blob/master/cloudformation/cloudformation-s3bucket-stack.yml) and place it somewhere in your repo, for example in location `./cloudformation/cloudformation-s3bucket-stack.yml`\n\nYou are welcome to change the stack as long as you don't change the following outputs:\n\n- `S3BucketName`\n- `CFDistributionRootId`\n- `CFDistributionPreviewId`\n\n### Step 2: Define your PR Comment Template\n\nUse the [provided pull request comment template](https://github.com/badsyntax/github-action-aws-static-stack/blob/master/.github/pr-comment-template.hbs) and place it somewhere in your repo, for example in location `.github/pr-comment-template.hbs`\n\n### Step 3: Define the Actions YAML\n\n```yaml\nname: 'Deploy'\n\nconcurrency:\n  group: deploy-${{ github.head_ref }}\n  cancel-in-progress: false\n\non:\n  repository_dispatch:\n  workflow_dispatch:\n  pull_request:\n    types: [opened, synchronize, reopened, closed]\n  push:\n    branches:\n      - master\n\njobs:\n  deploy:\n    name: 'Deploy'\n    runs-on: ubuntu-20.04\n    steps:\n      - uses: actions/checkout@v2\n\n      - name: Build\n        run: npm run build\n        if: github.event.action != 'closed'\n\n      - name: Configure AWS Credentials\n        uses: aws-actions/configure-aws-credentials@v1\n        if: github.actor != 'dependabot[bot]' \u0026\u0026 (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)\n        with:\n          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}\n          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}\n          aws-region: us-east-1\n\n      - uses: badsyntax/github-action-aws-static-stack@v0.0.8\n        name: Deploy Site\n        if: github.actor != 'dependabot[bot]' \u0026\u0026 (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)\n        with:\n          cf-stack-name: 'github-action-example-aws-static-stack'\n          cf-template: './cloudformation/cloudformation-s3bucket-stack.yml'\n          cf-apply-change-set: ${{ github.event_name != 'repository_dispatch' }}\n          token: ${{ secrets.GITHUB_TOKEN }}\n          aws-region: 'us-east-1'\n          s3-bucket-name: 'github-action-example-aws-static-stack-us-east-1'\n          s3-allowed-origins: 'https://example.com, https://*.preview.example.com'\n          cloudfront-root-hosts: 'example.com'\n          cloudfront-preview-hosts: '*.preview.example.com'\n          cloudfront-default-root-object: 'index'\n          certificate-arn: ${{ secrets.ROOT_DOMAIN_CERTIFICATE_ARN }}\n          src-dir: './out'\n          static-files-glob: '{css,js}/**/*'\n          lambda-version: '1.0.0'\n          delete-preview-site-on-pr-close: true\n          comment-template: '.github/pr-comment-template.hbs'\n```\n\n### Step 4: Deploy\n\nSend a pull request to your repository to create the stack and deploy a preview site.\n\nNote that `cf-apply-change-set` must be set to `true` to allow the stack to be created before attempting a deploy. The only time you don't want to set this is when the job is run via webhook (eg `repository_dispatch`).\n\n### Step 5: Adjust Domain Records\n\nCreate `CNAME` records that point to the relevant distribution.\n\nFor example I have the following records defined:\n\n```console\nstatic-example CNAME 1234abcd.cloudfront.net.\n*.preview.static-example CNAME 5678edfgh.cloudfront.net.\n```\n\nView more info on using a custom domain: \u003chttps://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html#CreatingCNAME\u003e\n\n## Action Inputs\n\nAll of the following inputs are required:\n\n| Name                              | Description                                                                                      | Example                                                                    |\n| --------------------------------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |\n| `cf-stack-name`                   | The name of the Cloudformation stack to be created                                               | `example-com-static-cloudformation-stack`                                  |\n| `cf-template`                     | The relative path to the CloudFormation stack template                                           | `./cloudformation/s3bucket_with_cloudfront.yml`                            |\n| `cf-apply-change-set`             | Whether to apply the CloudFormation ChangeSet (if any)                                           | `true`                                                                     |\n| `token`                           | GitHub Token used for commenting on Pull Requests                                                | `${{ secrets.GITHUB_TOKEN }}`                                              |\n| `aws-region`                      | 'The AWS region in which to create the stack. You should set this to `us-east-1`                 | `us-east-1`                                                                |\n| `s3-bucket-name`                  | The name of S3 bucket to be created, to store your static files. Must end with region name       | `example.com-us-east-1`                                                    |\n| `s3-allowed-origins`              | A list of allowed domains to request resources from S3                                           | `https://example.com,https://*.preview.example.com`                        |\n| `cloudfront-root-hosts`           | A list of hosts assigned to the Root CloudFront distribution                                     | `example.com`                                                              |\n| `cloudfront-preview-hosts`        | A list of hosts assigned to the Preview CloudFront distribution                                  | `*.preview.example.com`                                                    |\n| `cloudfront-default-root-object`  | The CloudFront default root object                                                               | `index`                                                                    |\n| `certificate-arn`                 | ARN of the certificate for the root and preview domains                                          | `arn:aws:acm:us-east-1:1234567:certificate/123abc-123abc-1234-5678-abcdef` |\n| `src-dir`                         | Path to build/out directory that contains the static files                                       | `./out`                                                                    |\n| `static-files-glob`               | Glob pattern for immutable static files                                                          | `_next/**`                                                                 |\n| `lambda-version`                  | The lambda version. Required to deploy a new lambda. You must update this if changing the lambda | `1.0.0`                                                                    |\n| `delete-preview-site-on-pr-close` | Whether to delete the preview site on PR close                                                   | `true`                                                                     |\n| `comment-template`                | Path to the Pull Request comment template                                                        | `.github/comment-template.md`                                              |\n\n## Action Outputs\n\n| Name           | Description                                                               | Example                   |\n| -------------- | ------------------------------------------------------------------------- | ------------------------- |\n| `modifiedKeys` | A comma separated list of modified object keys (either synced or removed) | `file1,folder1/file2.ext` |\n\n## Debugging\n\nCheck the Action output for logs.\n\nIf you need to see more verbose logs you can set `ACTIONS_STEP_DEBUG` to `true` as an Action Secret.\n\nDetailed stack logs can be found in CloudFormation in the AWS Console.\n\n## License\n\nSee [LICENSE.md](./LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadsyntax%2Fgithub-action-aws-static-stack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbadsyntax%2Fgithub-action-aws-static-stack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadsyntax%2Fgithub-action-aws-static-stack/lists"}