Skip to content

Commit 5bded73

Browse files
committed
trying random
1 parent 825a875 commit 5bded73

File tree

1 file changed

+41
-20
lines changed

1 file changed

+41
-20
lines changed
Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# AWS Example SAM Deploy: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/deploying-using-github.html
21
name: Deploy Lambda
32
on:
43
push:
@@ -15,7 +14,6 @@ on:
1514
- ".github/workflows/deploy_lambda.yml"
1615

1716
env:
18-
DEPLOY_LAMBDA: "true"
1917
STACK_NAME: api-python
2018
AWS_REGION: us-east-2
2119
LOGGING_LEVEL: INFO
@@ -24,50 +22,73 @@ env:
2422
jobs:
2523
sam-deploy:
2624
runs-on: ubuntu-latest
27-
if: ${{ env.DEPLOY_LAMBDA == 'true' }}
2825
steps:
2926
- uses: actions/checkout@v4
27+
3028
- uses: actions/setup-python@v5
3129
with:
3230
python-version: "3.12"
33-
cache: "poetry"
31+
32+
- name: Install and configure Poetry
33+
uses: snok/install-poetry@v1
34+
with:
35+
version: 1.7.1
36+
virtualenvs-create: true
37+
38+
- name: Load cached dependencies
39+
id: cached-poetry-dependencies
40+
uses: actions/cache@v3
41+
with:
42+
path: .venv
43+
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
44+
45+
- name: Install dependencies
46+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
47+
run: poetry install --no-interaction
48+
3449
- name: Run tests
35-
run: |
36-
pip install poetry
37-
poetry install --no-interaction
38-
poetry run pytest
50+
run: poetry run pytest
3951

40-
- uses: aws-actions/configure-aws-credentials@v1
52+
- uses: aws-actions/configure-aws-credentials@v4
4153
with:
4254
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
4355
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
4456
aws-region: ${{ env.AWS_REGION }}
4557

58+
- name: Login to Amazon ECR
59+
uses: aws-actions/amazon-ecr-login@v2
60+
61+
- name: Generate image tag
62+
id: image-tag
63+
run: |
64+
IMAGE_TAG=$(git rev-parse --short HEAD)
65+
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
66+
4667
- name: Get ECR URI
68+
id: ecr-uri
4769
run: |
4870
REPO_URI=$(aws cloudformation describe-stacks \
4971
--stack-name ${{ env.STACK_NAME }} \
5072
--query 'Stacks[0].Outputs[?OutputKey==`RepositoryUri`].OutputValue' \
5173
--output text)
74+
if [ -z "$REPO_URI" ]; then
75+
echo "Failed to get ECR repository URI"
76+
exit 1
77+
fi
5278
echo "REPO_URI=${REPO_URI}" >> $GITHUB_ENV
5379
54-
- name: Login to Amazon ECR
55-
uses: aws-actions/amazon-ecr-login@v1
56-
57-
- name: Generate image tag
58-
run: |
59-
IMAGE_TAG=$(git rev-parse --short HEAD)
60-
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
61-
6280
- name: Build and push image
6381
run: |
64-
docker build -f deploy/docker/Dockerfile -t ${{ env.REPO_URI }}:${{ env.IMAGE_TAG }} .
82+
docker build -f deploy/aws_sam/Dockerfile -t ${{ env.REPO_URI }}:${{ env.IMAGE_TAG }} .
6583
docker push ${{ env.REPO_URI }}:${{ env.IMAGE_TAG }}
6684
6785
- uses: aws-actions/setup-sam@v2
68-
- run: |
86+
87+
- name: Deploy with SAM
88+
run: |
6989
cd deploy/aws_sam
7090
sam deploy \
91+
--stack-name ${{ env.STACK_NAME }} \
7192
--no-confirm-changeset \
7293
--no-fail-on-empty-changeset \
7394
--parameter-overrides \
@@ -76,4 +97,4 @@ jobs:
7697
Workers="${{ env.WORKERS }}" \
7798
PostgresUri="${{ secrets.POSTGRES_URI }}" \
7899
Neo4jUri="${{ secrets.NEO4J_URI }}" \
79-
Neo4jPassword="${{ secrets.NEO4J_PASSWORD }}"
100+
Neo4jPassword="${{ secrets.NEO4J_PASSWORD }}" \

0 commit comments

Comments
 (0)