Skip to content

Force error from remote invoke #69

Force error from remote invoke

Force error from remote invoke #69

Workflow file for this run

name: FastAPI CI/CD Pipeline
on:
workflow_dispatch: {}
push:
branches:
- "terraform"
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: "3.10"
POETRY_VERSION: "1.5.1"
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
environment: dev
defaults:
run:
working-directory: "backend"
steps:
- name: Configure AWS Credentials For GitHub Actions
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ vars.AWS_ASSUME_ROLE_ARN }}
role-session-name: github-actions
aws-region: ap-southeast-2
- name: Setup SAM CLI
uses: aws-actions/setup-sam@v2
with:
use-installer: true
- name: Checkout code
uses: actions/checkout@v3
- name: Cache Poetry binary - Python ${{ env.PYTHON_VERSION }}
id: cache-bin-poetry
uses: actions/cache@v3
env:
SEGMENT_DOWNLOAD_TIMEOUT_MIN: "1"
with:
path: |
/opt/pipx/venvs/poetry
/opt/pipx_bin/poetry
# This step caches the poetry installation, so make sure it's keyed on the poetry version as well. From: https://github.com/langchain-ai/langchain/blob/b379c5f9c89199370d9175ce6ee34d469567e533/.github/workflows/_lint.yml#L12
key: bin-poetry-${{ runner.os }}-${{ runner.arch }}-py-${{ env.PYTHON_VERSION }}-${{ env.POETRY_VERSION }}
- name: Install poetry
if: steps.cache-bin-poetry.outputs.cache-hit != 'true'
shell: bash
run: pipx install "poetry==$POETRY_VERSION" --python "python$PYTHON_VERSION" --verbose
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
- run: poetry install
- name: Poetry export
run: poetry export -f requirements.txt --without-hashes > requirements.txt
- run: sam build --use-container
- name: sam deploy
# Prevent prompts and failure when the stack is unchanged
run: >
sam deploy
--no-confirm-changeset
--no-fail-on-empty-changeset
--stack-name fastapi-backend-lambda
--parameter-overrides "LambdaSecurityGroupId=${{ vars.LAMBDA_SG_ID }} LambdaSubnet1Id=${{ vars.LAMBDA_SUBNET_1_ID }} LambdaSubnet2Id=${{ vars.LAMBDA_SUBNET_2_ID }} SecretKeyArn=${{ vars.SECRET_ARN }} DBSecretArn=${{ vars.DB_SECRET_ARN }} DBEndpoint=${{ vars.DB_ENDPOINT }}"
- name: Run migrations
run: |
if sam remote invoke FastApiMigrationsFunction --stack-name fastapi-backend-lambda 2>&1 | cat | grep -q "Error"; then
exit 1
fi