feat(payment): correct timeout tx cronjob #91
Workflow file for this run
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: Build & Deploy | |
on: | |
pull_request: | |
branches: [ main, master, develop, stage ] | |
types: [ closed ] | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ap-southeast-1 | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} | |
ECR_REPOSITORY: lambda-handlers-image | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
build-and-test: | |
name: Build & Test | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:12-alpine | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_DB: matters-test | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
redis: | |
image: redis | |
ports: | |
- 6379:6379 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
- run: npm ci | |
- name: Lint | |
run: | | |
npm run lint \ | |
&& npm run format:check | |
- name: Build | |
run: npm run build | |
- name: Test | |
run: npm run test --if-present | |
env: | |
MATTERS_ENV: test | |
MATTERS_PG_HOST: localhost | |
MATTERS_PG_USER: postgres | |
MATTERS_PG_PASSWORD: postgres | |
MATTERS_PG_DATABASE: matters-test | |
MATTERS_NEW_FEATURE_TAG_ID: 1 | |
MATTERS_PG_RO_CONNECTION_STRING: postgresql://postgres:postgres@localhost/test_matters-test | |
MATTERS_CACHE_HOST: localhost | |
build-and-publish: | |
name: Build Lambda-Handlers Docker Image & Publish to AWS ECR | |
if: github.event.pull_request.merged == true | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
outputs: | |
output1: ${{ steps.step1.outputs.test }} | |
output2: ${{ steps.step2.outputs.test }} | |
registry: ${{ steps.login-ecr.outputs.registry }} | |
image_uri: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:v${{ steps.package-version.outputs.current-version }} | |
package-version: ${{ steps.package-version.outputs.current-version }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: get-npm-version | |
id: package-version | |
uses: martinbeentjes/npm-get-version-action@main | |
- name: Setup AWS | |
# if: github.base_ref == 'develop' || github.base_ref == 'stage' || github.base_ref == 'master' || github.base_ref == 'main' | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
# if: github.base_ref == 'develop' || github.base_ref == 'stage' || github.base_ref == 'master' || github.base_ref == 'main' | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build, tag, and push image to Amazon ECR | |
if: github.base_ref == 'main' | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile . | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
IMAGE_TAG: v${{ steps.package-version.outputs.current-version }} | |
IMAGE_URI: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:v${{ steps.package-version.outputs.current-version }} | |
deploy-check-motor-dev: | |
runs-on: 'ubuntu-latest' | |
environment: 'dev' | |
needs: build-and-publish | |
steps: | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: re-deploy Check Motor Lambda to dev | |
run: | | |
aws lambda update-function-code --function-name check-motor-badge-dev \ | |
--image-uri ${{ steps.login-ecr.outputs.registry }}/$ECR_REPOSITORY:$IMAGE_TAG | |
env: | |
IMAGE_URI: ${{ needs.build-and-publish.outputs.image_uri }} | |
IMAGE_TAG: v${{ needs.build-and-publish.outputs.package-version }} | |
deploy-check-motor-prod: | |
runs-on: 'ubuntu-latest' | |
environment: 'prod' | |
needs: [build-and-publish, deploy-check-motor-dev] | |
steps: | |
- name: re-deploy Check Motor Lambda | |
run: echo call lambda re-deploy check-motor-prod | |
check-motor-dev-running: | |
runs-on: 'ubuntu-latest' | |
environment: 'dev' | |
needs: [build-and-publish, deploy-check-motor-dev] | |
steps: | |
- name: Check if Motor Lambda running well on dev | |
run: echo Invoke AWS Lambda check-motor-dev running well && env | |
check-motor-prod-running: | |
runs-on: 'ubuntu-latest' | |
environment: 'dev' | |
needs: [build-and-publish, deploy-check-motor-prod] | |
steps: | |
- name: Check if Motor Lambda running well on prod | |
run: echo Invoke AWS Lambda if check-motor-prod running well && env | |
### Meili Indexer | |
deploy-meili-indexer-dev: | |
runs-on: 'ubuntu-latest' | |
environment: 'dev' | |
needs: build-and-publish | |
steps: | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: re-deploy Meili Indexer Lambda to dev | |
run: | | |
aws lambda update-function-code --function-name refresh-search-index-dev \ | |
--image-uri ${{ steps.login-ecr.outputs.registry }}/$ECR_REPOSITORY:$IMAGE_TAG | |
env: | |
IMAGE_TAG: v${{ needs.build-and-publish.outputs.package-version }} | |
deploy-meili-indexer-prod: | |
runs-on: 'ubuntu-latest' | |
environment: 'prod' | |
needs: [build-and-publish, deploy-meili-indexer-dev] | |
steps: | |
- name: re-deploy Meili Indexer Lambda to prod | |
run: echo call lambda re-deploy meili-indexer-prod | |
check-meili-indexer-running: | |
runs-on: 'ubuntu-latest' | |
environment: 'dev' | |
needs: [build-and-publish, deploy-meili-indexer-dev] | |
steps: | |
- name: Check if Meili Indexer Lambda running well on dev | |
run: echo Invoke AWS Lambda meili-indexer-dev running well | |
### User Retention | |
deploy-user-retention-dev: | |
runs-on: 'ubuntu-latest' | |
environment: 'dev' | |
needs: build-and-publish | |
steps: | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: re-deploy User Retention Lambda to dev | |
run: | | |
aws lambda update-function-code --function-name user-retention-dev \ | |
--image-uri ${{ steps.login-ecr.outputs.registry }}/$ECR_REPOSITORY:$IMAGE_TAG | |
env: | |
IMAGE_TAG: v${{ needs.build-and-publish.outputs.package-version }} | |
deploy-user-retention-sendmail-dev: | |
runs-on: 'ubuntu-latest' | |
environment: 'dev' | |
needs: build-and-publish | |
steps: | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: re-deploy User Retention Lambda to dev | |
run: | | |
aws lambda update-function-code --function-name user-retention-sendmail-dev \ | |
--image-uri ${{ steps.login-ecr.outputs.registry }}/$ECR_REPOSITORY:$IMAGE_TAG | |
env: | |
IMAGE_TAG: v${{ needs.build-and-publish.outputs.package-version }} | |
### User Likecoin | |
deploy-likecoin-like-dev: | |
runs-on: 'ubuntu-latest' | |
environment: 'dev' | |
needs: build-and-publish | |
steps: | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: re-deploy Likecoin Like Lambda to dev | |
run: | | |
aws lambda update-function-code --function-name likecoin-like-dev \ | |
--image-uri ${{ steps.login-ecr.outputs.registry }}/$ECR_REPOSITORY:$IMAGE_TAG | |
env: | |
IMAGE_TAG: v${{ needs.build-and-publish.outputs.package-version }} | |
deploy-likecoin-update-civic-liker-cache-dev: | |
runs-on: 'ubuntu-latest' | |
environment: 'dev' | |
needs: build-and-publish | |
steps: | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: re-deploy Likecoin likecoin-update-civic-liker-cache Lambda to dev | |
run: | | |
aws lambda update-function-code --function-name likecoin-update-civic-liker-cache-dev \ | |
--image-uri ${{ steps.login-ecr.outputs.registry }}/$ECR_REPOSITORY:$IMAGE_TAG | |
env: | |
IMAGE_TAG: v${{ needs.build-and-publish.outputs.package-version }} |