-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: 인프라 변경을 위한 github actions 작성 (#76)
- Loading branch information
1 parent
6d3b7e7
commit 07fe3d7
Showing
3 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: AWS deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- feature/76-infra-change-aws | ||
|
||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
environment: production | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure 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: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
id: build-image | ||
uses: docker/build-push-action@v3 | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: ${{ secrets.AWS_CONTAINER_REGISTRY }} | ||
IMAGE_TAG: latest | ||
with: | ||
file: ./Dockerfile.ecs | ||
context: . | ||
push: true | ||
tags: ${{ steps.login-ecr.outputs.registry }}/${{ secrets.AWS_CONTAINER_REGISTRY }}:latest | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
secrets: | | ||
GIT_AUTH_TOKEN=${{ secrets.GIT_TOKEN }} | ||
- name: Build Image Path | ||
id: image-path | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: ${{ secrets.AWS_CONTAINER_REGISTRY }} | ||
IMAGE_TAG: latest | ||
run: | | ||
echo "ecs-deploy=${{ steps.login-ecr.outputs.registry }}/${{ secrets.AWS_CONTAINER_REGISTRY }}:latest" >> $GITHUB_OUTPUT | ||
- name: Download task definition | ||
run: | | ||
aws ecs describe-task-definition \ | ||
--task-definition ${{secrets.TASK_DEFINITION_NAME}} \ | ||
--query taskDefinition \ | ||
> ecs-deploy-task-definition.json | ||
- name: Deploy Amazon ECS task definition | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
task-definition: ecs-deploy-task-definition.json | ||
service: ${{secrets.ECS_SERVICE}} | ||
cluster: ${{secrets.ECS_CLUSTER}} | ||
wait-for-service-stability: true | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM node:22-alpine | ||
|
||
WORKDIR /app | ||
|
||
COPY package*.json ./ | ||
|
||
RUN npm install | ||
|
||
COPY test.js ./ | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["node", "test.js"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const http = require("http"); | ||
|
||
const server = http.createServer((req, res) => { | ||
res.writeHead(200, { "Content-Type": "text/plain" }); | ||
res.end("Hello"); | ||
}); | ||
|
||
server.listen(3000, () => { | ||
console.log("Server running on port 3000"); | ||
}); |