Skip to content

Commit

Permalink
setting: github acitons 작성
Browse files Browse the repository at this point in the history
- 도커 이미지 빌드
- AWS ECR에 이미지 업로드
- 이미지 태그 업로드 확인용 커밋 푸시
  • Loading branch information
shren207 committed Feb 29, 2024
1 parent 4c31fb3 commit 726202b
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and Deploy

on:
push:
branches: [ "master" ]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- 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: ap-northeast-2

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
id: build-and-push
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: green-blog-co
IMAGE_TAG: ${{ github.sha }}
run: |
docker buildx build --platform linux/amd64 -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
echo "image=$REGISTRY/$REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Commit and Push
run: |
git config --global user.name "shren207"
git config --global user.email "[email protected]"
git commit -am "Update image to ${{ github.sha }}"
git push

0 comments on commit 726202b

Please sign in to comment.