Skip to content

Merge pull request #1 from josh-stillman/js/add-news-feed #5

Merge pull request #1 from josh-stillman/js/add-news-feed

Merge pull request #1 from josh-stillman/js/add-news-feed #5

Workflow file for this run

name: Deploy Next.js site to AWS
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "frontend"
cancel-in-progress: false
jobs:
# Build job
build-and-deploy:
runs-on: ubuntu-latest
env:
NEXT_PUBLIC_API_URL: ${{ secrets.API_URL }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "18"
cache: "npm"
- name: Restore cache
uses: actions/cache@v3
with:
path: |
.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Install Modules
run: npm ci
- name: Build Application
run: npm run build
# Deploy to AWS
- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Deploy to S3
run: aws s3 sync ./out s3://${{ secrets.BUCKET_NAME }} --delete
- name: Create Cloudfront Invalidation
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.DISTRIBUTION_ID }} --paths "/*"