Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #33 from Locomotive-Ventures/s3-deploy
Browse files Browse the repository at this point in the history
feat: S3 Deployment Workflow
  • Loading branch information
vincentkoc authored Nov 25, 2023
2 parents a69f4d5 + 60f032a commit 7135386
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 1 deletion.
88 changes: 88 additions & 0 deletions .github/workflows/deploy_s3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: 'Terraform'

on:
pull_request:
paths:
- 'frontend/**'
- '.github/workflows/deploy_s3.yml'
branches:
- main

permissions:
contents: read
pull-requests: write

#concurrency, we should only ever run this once across the entire repository
concurrency:
group: deploys3
cancel-in-progress: true

jobs:
build-s3:
name: 'Build S3'
runs-on: ubuntu-latest
environment: deploys3

# Use the Bash shell regardless of the GitHub Actions runner's OS
defaults:
run:
shell: bash

steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v3

# Cache Node.js dependencies
- name: Cache Node.js dependencies
uses: actions/cache@v2
with:
path: frontend/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('frontend/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
# Install dependencies
- name: Install dependencies
run: npm install
working-directory: frontend

# Build, and test
- name: Build
run: npm run build
working-directory: frontend

- name: Archive production build
uses: actions/upload-artifact@v2
with:
name: frontend-artifact
path: frontend/build

deploy-s3:
needs: build-s3
name: 'Deploy S3'
runs-on: ubuntu-latest
environment: deploys3

# Use the Bash shell regardless of the GitHub Actions runner's OS
defaults:
run:
shell: bash

steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v3

# Configure AWS CLI (required for S3 backend)
- name: Configure AWS Credentials
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: 'ap-southeast-2'

# Deploy frontend to s3 bucket using AWS CLI
- name: Deploy to S3
run: |
aws s3 sync ./frontend/ s3://wombat-warden-s3-static-website/ --delete
2 changes: 1 addition & 1 deletion .github/workflows/terraform_plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
paths:
- 'infrastructure/**'
- '.github/workflows/**'
- '.github/workflows/terraform**'
branches:
- main

Expand Down

0 comments on commit 7135386

Please sign in to comment.