Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy Lambda
name: Deploy

on:
workflow_call:
Expand All @@ -11,8 +11,8 @@ on:
description: "AWS region"
required: true
type: string
branch:
description: "The branch to deploy"
ref:
description: "The ref to deploy"
required: true
type: string

Expand All @@ -21,25 +21,22 @@ jobs:
name: Deploy - ${{ inputs.environment }}
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
concurrency:
group: deploy-${{ inputs.environment }}
cancel-in-progress: false
permissions:
id-token: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
ref: ${{ inputs.ref }}

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm run test
node-version: "lts/*"

- name: Install Serverless
run: npm install -g serverless
Expand All @@ -51,7 +48,7 @@ jobs:
role-to-assume: ${{ secrets.AWS_STS_ROLE }}

- name: Deploy Lambda
run: serverless deploy --stage ${{ inputs.environment }}
run: serverless deploy --stage ${{ inputs.environment }} --wait
env:
MEMBERS_TABLE: ${{ vars.MEMBERS_TABLE }}
CONTRACTS_TABLE: ${{ vars.CONTRACTS_TABLE }}
Expand All @@ -62,9 +59,6 @@ jobs:
SQS_ARN: ${{ vars.SQS_ARN }}
SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}

- name: Wait for deployment
run: sleep 10

- name: Cleanup
run: serverless remove --stage ${{ inputs.environment }}
env:
Expand Down
23 changes: 0 additions & 23 deletions .github/workflows/deploy_dev.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/deploy_on_approval.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy to Dev on Approval

on:
pull_request_review:
types: [submitted]

jobs:
check_review:
runs-on: ubuntu-latest
if: github.event.review.state == 'approved' && github.event.pull_request.base.ref == 'main'
steps:
- run: echo "PR was approved, proceeding with tests"

run_tests:
needs: check_review
uses: ./.github/workflows/lint_test.yml

deploy_to_dev:
needs: run_tests
uses: ./.github/workflows/deploy.yml
with:
environment: dev
aws_region: ap-southeast-2
ref: ${{ github.event.pull_request.head.ref }}
secrets: inherit
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
name: Deploy - prod
name: Deploy Pipeline

on:
push:
branches:
- main

permissions:
id-token: write
contents: read
branches: ["main"]

jobs:
run_tests:
uses: ./.github/workflows/lint_test.yml
with:
ref: ${{ github.ref_name }}

deploy_to_dev:
needs: run_tests
uses: ./.github/workflows/deploy.yml
with:
environment: dev
aws_region: ap-southeast-2
branch: main
ref: ${{ github.ref_name }}
secrets: inherit

deploy_to_prod:
uses: ./.github/workflows/deploy.yml
needs: deploy_to_dev
uses: ./.github/workflows/deploy.yml
with:
environment: prod
aws_region: ap-southeast-1
branch: main
aws_region: ap-southeast-2
ref: ${{ github.ref_name }}
secrets: inherit
35 changes: 35 additions & 0 deletions .github/workflows/lint_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Lint and Test

on:
workflow_call:
inputs:
ref:
description: "The ref to lint and test"
required: true
type: string

permissions:
id-token: write
contents: read

jobs:
lint_test:
runs-on: ubuntu-latest
env:
NODE_ENV: test
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm run test
14 changes: 14 additions & 0 deletions .github/workflows/validate_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Validate PR

# This workflow is used to validate a pull request before it is merged into the main branch.
on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]

jobs:
lint_test:
if: github.event.pull_request.draft == false
uses: ./.github/workflows/lint_test.yml
with:
ref: ${{ github.event.pull_request.head.ref }}
1 change: 1 addition & 0 deletions .nvm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/*
Loading