Skip to content

Commit

Permalink
add action for dev env
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Stillman committed Sep 7, 2023
1 parent 9c3263d commit 275e183
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
on:
workflow_call:

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 "/*"
20 changes: 20 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
on:
# Runs on pushes targeting the default branch
push:
branches: ["dev"]

# 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-dev"
cancel-in-progress: false

jobs:
build-deploy-dev:
uses: ./.github/workflows/dev.yml
environment: dev
secrets: inherit

0 comments on commit 275e183

Please sign in to comment.