Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added staging lambda deploy #429

Merged
merged 7 commits into from
Oct 13, 2024
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
12 changes: 10 additions & 2 deletions .github/workflows/nameguard-api-lambda-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- main
- ci
- staging
paths:
- "api/**"
- ".github/workflows/nameguard-api-lambda-deploy.yml"
Expand Down Expand Up @@ -65,7 +65,15 @@ jobs:
ALCHEMY_URI_SEPOLIA: ${{ secrets.ALCHEMY_URI_SEPOLIA }}
ENS_SUBGRAPH_URL_MAINNET: ${{ secrets.ENS_SUBGRAPH_URL_MAINNET }}
ENS_SUBGRAPH_URL_SEPOLIA: ${{ secrets.ENS_SUBGRAPH_URL_SEPOLIA }}
run: pnpm run deploy:prod
run: |
if [[ ${{ github.ref }} == 'refs/heads/main' ]]; then
pnpm run deploy:prod
elif [[ ${{ github.ref }} == 'refs/heads/staging' ]]; then
pnpm run deploy:staging
else
echo "Deployment is only supported for main and staging branches"
exit 1
fi
working-directory: api

- name: Delete old images from ECR
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nameguard-api-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches:
- main
pull_request:
branches: ["main"]
branches: ["main", "staging"]
jobs:
lint:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nameguard-api-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
pull_request:
branches:
- main
- staging
paths:
- "api/**"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nameguard-end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ on:
push:
branches:
- main
- ci
- staging
paths:
- "packages/nameguard-sdk/**"
- "api/nameguard/**"
- ".github/workflows/nameguard-end-to-end-tests.yml"
pull_request:
branches:
- main
- ci
- staging
paths:
- "packages/nameguard-sdk/**"
- "api/nameguard/**"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/typescript-packages-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ on:
push:
branches:
- main
- ci
- staging
paths:
- "packages/**"
pull_request:
branches:
- main
- ci
- staging
paths:
- "packages/**"

Expand Down
3 changes: 2 additions & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"NameHash"
],
"scripts": {
"deploy:prod": "DOCKER_CONFIG=./.docker serverless deploy --stage prod"
"deploy:prod": "DOCKER_CONFIG=./.docker serverless deploy --stage prod",
"deploy:staging": "DOCKER_CONFIG=./.docker serverless deploy --stage staging"
},
"dependencies": {
"serverless": "3.39.0"
Expand Down
16 changes: 13 additions & 3 deletions api/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
service: oss-nameguard

stages:
staging:
alias: api-staging.nameguard.io
lambda-role: DefaultNameGuardRoleStaging
lambda-policy-name: NameGuardPolicyStaging
prod:
alias: api.nameguard.io
lambda-role: DefaultNameGuardRole
lambda-policy-name: NameGuardPolicy

custom:
stage: ${opt:stage}
apiDomain: api.nameguard.io
apiDomain: ${self:stages.${self:custom.stage}.alias}
hostedZoneName: nameguard.io.
hostedZoneId: Z00825691ZLCWE2VKJQW0
prune:
Expand Down Expand Up @@ -49,7 +59,7 @@ resources:
Type: AWS::IAM::Role
Properties:
Path: /my/default/path/
RoleName: DefaultNameGuardRole # required if you want to use 'serverless deploy --function' later on
RoleName: ${self:stages.${self:custom.stage}.lambda-role}
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
Expand All @@ -59,7 +69,7 @@ resources:
- lambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: NameGuardPolicy
- PolicyName: ${self:stages.${self:custom.stage}.lambda-policy-name}
PolicyDocument:
Version: "2012-10-17"
Statement:
Expand Down