Merge pull request #90 from Perry2004/dependabot/npm_and_yarn/npm_and… #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Build artifacts and push to S3 | |
| name: Publish to S3 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - scripts/** | |
| - README.md | |
| - .github/workflows/** | |
| workflow_dispatch: | |
| jobs: | |
| push-artifacts-to-s3: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_IAM_ROLE_ARN }} | |
| aws-region: ${{ vars.AWS_REGION }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "yarn" | |
| - name: Install Dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Build Project | |
| run: yarn cibuild | |
| - name: Deploy to S3 | |
| run: | | |
| aws s3 sync ./dist s3://${{ vars.AWS_S3_BUCKET }}/website --delete | |
| - name: Regenerate rolling images | |
| run: | | |
| aws lambda invoke \ | |
| --function-name "${{ vars.AWS_LAMBDA_FUNCTION_NAME }}" \ | |
| --payload '{}' \ | |
| --cli-binary-format raw-in-base64-out \ | |
| lambda-response.json > lambda-invoke.json | |
| cat lambda-invoke.json | |
| cat lambda-response.json | |
| if jq -e '.FunctionError' lambda-invoke.json > /dev/null; then | |
| echo "Lambda invocation failed:" | |
| cat lambda-invoke.json | |
| exit 1 | |
| fi | |
| if ! jq -e '.statusCode == 200' lambda-response.json > /dev/null; then | |
| echo "Lambda returned a non-200 status code:" | |
| cat lambda-response.json | |
| exit 1 | |
| fi | |
| if ! jq -e '(.body | fromjson | .success) == true' lambda-response.json > /dev/null; then | |
| echo "Lambda did not regenerate rolling images successfully:" | |
| cat lambda-response.json | |
| exit 1 | |
| fi | |
| - name: Invalidate CloudFront cache | |
| uses: foxdalas/cloudfront-invalidator@v4 | |
| with: | |
| tag_key: "Name" | |
| tag_value: ${{ vars.CLOUDFRONT_DISTRIBUTION_NAME }} | |
| paths: "/*" |