Merge pull request #163 from cisagov/RSC-Dashboard #127
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
--- | |
name: Frontend Pipeline | |
on: | |
push: | |
branches: | |
- develop | |
- production | |
paths: | |
- 'frontend/**' | |
- '.github/workflows/frontend.yml' | |
pull_request: | |
branches: | |
- develop | |
- production | |
paths: | |
- 'frontend/**' | |
- '.github/workflows/frontend.yml' | |
defaults: | |
run: | |
working-directory: ./frontend | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Restore npm cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: ${{ runner.os }}-node- | |
- name: Install dependencies | |
run: npm ci | |
- name: Lint | |
run: npm run lint | |
test: | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Restore npm cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: ${{ runner.os }}-node- | |
- name: Install dependencies | |
run: npm ci | |
- name: Build | |
run: npm run build | |
- name: Test | |
run: npm run test | |
deploy_staging: | |
needs: [lint, test] | |
runs-on: ubuntu-latest | |
environment: staging | |
concurrency: '1' | |
if: github.event_name == 'push' && github.ref == 'refs/heads/develop' | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Restore npm cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: ${{ runner.os }}-node- | |
- name: Install dependencies | |
run: npm ci | |
- name: Build Staging | |
run: cp stage.env .env && npm run build | |
- name: Deploy Staging | |
run: npx sls deploy --stage=staging | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
SLS_DEBUG: '*' | |
deploy_prod: | |
needs: [lint, test] | |
runs-on: ubuntu-latest | |
environment: production | |
concurrency: '1' | |
if: github.event_name == 'push' && github.ref == 'refs/heads/production' | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Restore npm cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: ${{ runner.os }}-node- | |
- name: Install dependencies | |
run: npm ci | |
- name: Build Production | |
run: cp prod.env .env && npm run build | |
- name: Deploy Production | |
run: npx sls deploy --stage=staging | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
SLS_DEBUG: '*' |