Skip to content

Commit

Permalink
Merge pull request #706 from byu-oit/split-up-deploy
Browse files Browse the repository at this point in the history
Split up `Deploy` workflow into multiple jobs
  • Loading branch information
GaryGSC authored Oct 31, 2022
2 parents 70e620c + 3055079 commit b640713
Showing 1 changed file with 83 additions and 23 deletions.
106 changes: 83 additions & 23 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,9 @@ jobs:
outputs:
matrix: ${{ env.matrix }}

build_and_deploy:
name: Build and Deploy
test:
name: Test
runs-on: ubuntu-latest
needs: env
strategy:
matrix: ${{ fromJson(needs.env.outputs.matrix) }}
fail-fast: false
environment:
name: ${{ matrix.env.environment_name }}
url: https://${{ steps.url.outputs.stdout }}
steps:
- name: Check out
uses: actions/checkout@v3
Expand All @@ -108,19 +101,11 @@ jobs:
cache: npm
cache-dependency-path: '**/package-lock.json'

- name: Audit
working-directory: src
run: npm audit --audit-level=critical

- name: Build
- name: npm ci
working-directory: src
run: npm ci --prefer-offline

- name: Lint
working-directory: src
run: npm run lint

- name: Test
- name: npm test
working-directory: src
run: npm test

Expand All @@ -130,6 +115,85 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

audit:
name: Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.node_version }}

# We don't need to install deps to audit them

- name: npm audit
working-directory: src
run: npm audit --audit-level=critical

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.node_version }}
cache: npm
cache-dependency-path: '**/package-lock.json'

- name: npm ci
working-directory: src
run: npm ci --prefer-offline

- name: npm lint
working-directory: src
run: npm run lint

hadolint:
name: Lint Docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# Hadolint follows semantic versioning, but doesn't have a @v2 release
- name: Lint Dockerfile
uses: hadolint/hadolint-action@v2.1.0
with:
dockerfile: src/Dockerfile

format:
name: Terraform Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Terraform Setup
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ env.tf_version }}

- name: Terraform Format
working-directory: terraform-iac
run: terraform fmt -check -recursive

build_and_deploy:
name: Build and Deploy
runs-on: ubuntu-latest
needs: [env, test, audit, lint, hadolint, format]
strategy:
matrix: ${{ fromJson(needs.env.outputs.matrix) }}
fail-fast: false
environment:
name: ${{ matrix.env.environment_name }}
url: https://${{ steps.url.outputs.stdout }}
steps:
- name: Check out
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
Expand Down Expand Up @@ -176,10 +240,6 @@ jobs:
working-directory: ${{ matrix.env.tf_working_dir }}
run: terraform init

- name: Terraform Format
working-directory: "./"
run: terraform fmt -check -recursive

- name: Terraform Plan
working-directory: ${{ matrix.env.tf_working_dir }}
run: terraform plan -var 'image_tag=${{ steps.date.outputs.timestamp }}' -input=false -out=plan
Expand Down

0 comments on commit b640713

Please sign in to comment.