Upload to S3 + CloudFront invalidation

Reference

name: Upload to S3 and invalidate CloudFront cache
uses: BYM-IKT/github-actions/upload-to-s3-and-invalidate-cloudfront@master
with:
  aws-account-id:                      ${{ inputs.aws-account-id }}
  s3-bucket-name:                      test-kattehotell-client
  build-directory:                     ./build
  cloudfront-distribution-domain-name: https://kattehotell.test.bymoslo.net

Examples

Build with pnpm and push to S3

If you have the following project structure:

Your project
.
├── .github/
│   └── workflows/          
│       └── deploy_to_test.yml
├── ...
├── .env
├── .env.test
├── .env.prod
├── index.html
├── ipnpm-lock.yaml
└── package.json

You can design your GitHub Actions workflow as follows:

.github/workflows/deploy_to_test.yml
name: Build and deploy to TEST

jobs:
  deploy:
    name: Build app and deploy to TEST
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read
    environment: 
      name: testing
      url:  https://kattehotell.test.bymoslo.net
    steps:
      - uses: actions/checkout@v6

      - uses: pnpm/action-setup@v4
        with:
          version: 10
          package_json_file: ./package.json

      - uses: actions/setup-node@v6
        with:
          node-version: 24
          cache: pnpm
          cache-dependency-path: ./pnpm-lock.yaml

      - name: Install dependencies
        run: pnpm install

      - name: Build
        env:
          CI: false
        run: pnpm build --mode test --emptyOutDir --outDir 'build'

      - name: Upload to S3 and invalidate CloudFront cache
        uses: BYM-IKT/github-actions/upload-to-s3-and-invalidate-cloudfront@master
        with:
          aws-account-id:                      "<<AWS-ACCOUNT-ID>>"
          s3-bucket-name:                      test-kattehotell-client
          build-directory:                     build
          cloudfront-distribution-domain-name: https://kattehotell.test.bymoslo.net