-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5efdcfc
commit 38eb560
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Frontend Prod CI/CD Pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
env: | ||
project-directory: ./ | ||
|
||
jobs: | ||
frontend: | ||
name: Build Frontend Project | ||
runs-on: ubuntu-latest | ||
if: | | ||
!contains(github.event.head_commit.message, 'skip-ci') | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js 12.x | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12.x' | ||
- name: npm clean install | ||
run: npm ci | ||
working-directory: ${{ env.project-directory }} | ||
- name: run ESLint | ||
run: npm run lint | ||
working-directory: ${{ env.project-directory }} | ||
# define the endpoints for PROD in github secrets | ||
- name: build frontend project | ||
run: ${{ secrets.PROD_APP_ENDPOINTS }} npm run build | ||
working-directory: ${{ env.project-directory }} | ||
- uses: actions/upload-artifact@v2 | ||
if: github.event_name == 'push' && github.repository == "Greenstand/${{ github.event.repository.name }}" | ||
with: | ||
name: frontend-bundle | ||
path: build | ||
- name: run React tests | ||
run: npm test | ||
working-directory: ${{ env.project-directory }} | ||
|
||
deploy: | ||
name: Deploy to PROD CDN | ||
runs-on: ubuntu-latest | ||
needs: frontend | ||
if: | | ||
!contains(github.event.head_commit.message, 'skip-ci') && | ||
github.event_name == 'push' && | ||
github.repository == "Greenstand/${{ github.event.repository.name }}" | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Download bundled frontend resources | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: frontend-bundle | ||
path: build | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET }} | ||
aws-region: us-east-1 | ||
- name: Copy front end resources to s3 bucket | ||
run: | | ||
aws s3 sync build s3://${{ secrets.PROD_CDN_S3_BUCKET }} --delete | ||
- name: Invalidate cloudfront caches | ||
run: | | ||
aws cloudfront create-invalidation --distribution-id ${{ secrets.PROD_CDN_DISTRIBUTION_ID }} --paths "/*" |