fix: use github secrets for db credentials
This commit is contained in:
18
.github/workflows/ci-cd.yml
vendored
18
.github/workflows/ci-cd.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Configure AWS credentials
|
- name: Configure AWS credentials
|
||||||
uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83
|
uses: aws-actions/configure-aws-credentials@v6
|
||||||
with:
|
with:
|
||||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
@@ -33,23 +33,27 @@ jobs:
|
|||||||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
||||||
IMAGE_TAG: ${{ github.sha }}
|
IMAGE_TAG: ${{ github.sha }}
|
||||||
run: |
|
run: |
|
||||||
docker build -t $ECR_REGISTRY/stan/personal-website:$IMAGE_TAG packages/web
|
docker build \
|
||||||
|
--build-arg DB_HOST=${{ secrets.DB_HOST }} \
|
||||||
|
--build-arg DB_USER=${{ secrets.DB_USER }} \
|
||||||
|
--build-arg DB_PASSWORD=${{ secrets.DB_PASSWORD }} \
|
||||||
|
-t $ECR_REGISTRY/stan/personal-website:$IMAGE_TAG \
|
||||||
|
packages/web
|
||||||
docker push $ECR_REGISTRY/stan/personal-website:$IMAGE_TAG
|
docker push $ECR_REGISTRY/stan/personal-website:$IMAGE_TAG
|
||||||
echo "image=$ECR_REGISTRY/stan/personal-website:$IMAGE_TAG" >> $GITHUB_OUTPUT
|
echo "image=$ECR_REGISTRY/stan/personal-website:$IMAGE_TAG" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Fill in the new image ID in the Amazon ECS task definition
|
- name: Render ECS Task Definition
|
||||||
id: task-def
|
id: task-def
|
||||||
uses: aws-actions/amazon-ecs-render-task-definition@c804dfbdd57f713b6c079302a4c01db7017a36fc
|
uses: aws-actions/amazon-ecs-render-task-definition@v1
|
||||||
with:
|
with:
|
||||||
task-definition: .github/workflows/taskdef.json
|
task-definition: .github/workflows/taskdef.json
|
||||||
container-name: web
|
container-name: web
|
||||||
image: ${{ steps.build-image.outputs.image }}
|
image: ${{ steps.build-image.outputs.image }}
|
||||||
|
|
||||||
- name: Deploy Amazon ECS task definition
|
- name: Deploy to Amazon ECS
|
||||||
uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a
|
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
|
||||||
with:
|
with:
|
||||||
task-definition: ${{ steps.task-def.outputs.task-definition }}
|
task-definition: ${{ steps.task-def.outputs.task-definition }}
|
||||||
service: main-service
|
service: main-service
|
||||||
cluster: PersonalWebsiteCluster
|
cluster: PersonalWebsiteCluster
|
||||||
wait-for-service-stability: true
|
wait-for-service-stability: true
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ COPY package.json bun.lockb ./
|
|||||||
RUN bun install
|
RUN bun install
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
ENV DB_HOST=host
|
ARG DB_HOST
|
||||||
ENV DB_USER=user
|
ARG DB_USER
|
||||||
ENV DB_PASSWORD=password
|
ARG DB_PASSWORD
|
||||||
|
|
||||||
|
|
||||||
RUN bun run build
|
RUN bun run build
|
||||||
|
|||||||
Reference in New Issue
Block a user