Skip to content

DYNAMODB_TABLE: ${{ env.DYNAMODB_TABLE }} #91

DYNAMODB_TABLE: ${{ env.DYNAMODB_TABLE }}

DYNAMODB_TABLE: ${{ env.DYNAMODB_TABLE }} #91

Workflow file for this run

name: Deploy Environment
on:
push:
branches:
- main
workflow_dispatch:
permissions:
id-token: write
contents: read
env:
aws_account_id: ${{ vars.AWS_ACCOUNT_ID }}
aws_region: ${{ vars.AWS_REGION }}
aws_role: ${{ vars.AWS_ROLE }}
DYNAMODB_LOCAL_AWS_REGION: local
DYNAMODB_LOCAL_ENDPOINT: http://localhost:8000
AWS_ACCESS_KEY_ID: DUMMYIDEXAMPLE
AWS_SECRET_ACCESS_KEY: DUMMYIDEXAMPLE
DYNAMODB_TABLE: stateful_aws_api_tasks
jobs:
test:
runs-on: ubuntu-latest
services:
dynamodb-local:
image: "amazon/dynamodb-local:latest"
ports:
- "8000:8000"
options: --health-cmd="curl -s -o /dev/null -I -w "%{http_code}" http://localhost:8000 | grep -q 400 || exit 1" --health-interval=1s --health-timeout=2s --health-retries=10
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: create table
run: aws dynamodb create-table --endpoint-url ${{ env.DYNAMODB_LOCAL_ENDPOINT }} --region ${{ env.DYNAMODB_LOCAL_AWS_REGION }} --table-name ${{ env.DYNAMODB_TABLE }} --billing-mode PAY_PER_REQUEST --key-schema AttributeName=id,KeyType=HASH --attribute-definitions AttributeName=id,AttributeType=S AttributeName=title,AttributeType=S --global-secondary-indexes "IndexName=IpIndex,KeySchema=[{AttributeName=title,KeyType=HASH}],Projection={ProjectionType=ALL}"
- name: list table
run: aws dynamodb list-tables --endpoint-url ${{ env.DYNAMODB_LOCAL_ENDPOINT }} --region ${{ env.DYNAMODB_LOCAL_AWS_REGION }}
- name: install
run: npm install --omit=dev
- name: run
run: nohup npx ts-node src/app.local.ts > ${GITHUB_WORKSPACE}/output.log 2>&1 &
- name: test
env:
API_PORT: 9000
DYNAMODB_AWS_REGION: ${{ env.DYNAMODB_LOCAL_AWS_REGION }}
DYNAMODB_ENDPOINT: ${{ env.DYNAMODB_LOCAL_ENDPOINT }}
DYNAMODB_TABLE: ${{ env.DYNAMODB_TABLE }}
run: |
sleep 5
cat ${GITHUB_WORKSPACE}/output.log
curl http://localhost:9000/hello
# - name: run app
# run: |
# docker run -d -p 9000:9000 --network host --env-file ${GITHUB_WORKSPACE}/.env ci:app
# - name: test
# run: |
# curl -s -o /dev/null -I -w "%{http_code}" http://localhost:9000/hello 2>/dev/null
# docker logs ci:app
# # BASE_URL=http://localhost:9000 npm run ci:test
# deploy:
# needs: test
# runs-on: ubuntu-latest
# steps:
# - name: checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - uses: extractions/setup-just@v2
# - uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-region: ${{ env.aws_region }}
# role-to-assume: arn:aws:iam::${{ env.aws_account_id }}:role/${{ env.aws_role }}
# role-session-name: GitHubActions
# - name: build
# shell: bash
# run: just build
# - name: tf-apply
# shell: bash
# run: just tf-apply
# - name: tf-set-envs
# shell: bash
# run: |
# cd tf
# URL=$(terraform output -raw url)
# echo "URL=$URL"
# echo "URL=$URL" >> $GITHUB_ENV
# clean:
# if: always()
# needs:
# - deploy
# runs-on: ubuntu-latest
# steps:
# - name: checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - uses: extractions/setup-just@v2
# - uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-region: ${{ env.aws_region }}
# role-to-assume: arn:aws:iam::${{ env.aws_account_id }}:role/${{ env.aws_role }}
# role-session-name: GitHubActions
# - name: destroy
# shell: bash
# run: just destroy