Merge pull request #5 from KMA-Score/revert-4-main #13
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: Deploy KMA Score API - Prod environment | |
env: | |
DB_URL: ${{ secrets.DB_URL }} | |
CERTIFICATE_ARN: ${{ secrets.CERTIFICATE_ARN }} | |
on: | |
push: | |
branches: [main] | |
jobs: | |
deploy: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout main branch | |
uses: actions/checkout@v2 | |
- name: Setup AWS Credentials | |
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: ap-southeast-1 | |
- name: Get SSMS parameters | |
uses: dkershner6/aws-ssm-getparameters-action@v1 | |
with: | |
parameterPairs: "/region/primary = ap-southeast-1, | |
/sst/kma-score-serverless/prod/Secret/DB_HOST/value=DB_HOST, | |
/sst/kma-score-serverless/prod/Secret/DB_NAME/value=DB_NAME, | |
/sst/kma-score-serverless/prod/Secret/DB_PASSWORD/value=DB_PASSWORD, | |
/sst/kma-score-serverless/prod/Secret/DB_PORT/value=DB_PORT, | |
/sst/kma-score-serverless/prod/Secret/DB_USERNAME/value=DB_USERNAME" | |
withDecryption: "true" | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
with: | |
version: 8 | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm i --frozen-lockfile | |
- name: Lint | |
run: pnpm lint && pnpm typecheck | |
# https://stackoverflow.com/questions/68119012/create-env-file-in-gh-action-using-repo-secrets | |
- name: Apply all pending migrations to the database | |
run: | | |
echo $DB_URL > .env | |
pnpm db:migrate | |
working-directory: packages/core | |
- name: Deploy | |
run: pnpm sst deploy --stage prod | |