Skip to content

Commit

Permalink
Merge pull request #12 from Techeer-Hogwarts/SCRUM-152--actions
Browse files Browse the repository at this point in the history
feat: docker hub login
  • Loading branch information
printSANO authored Oct 27, 2024
2 parents b808059 + 4563035 commit 801f22c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set Docker Image Tag
id: set_docker_image_tag
env:
PR_NUMBER: ${{ steps.get_pr_number.outputs.PR_NUMBER }}
run: |
Expand All @@ -46,3 +47,33 @@ jobs:
DOCKER_IMAGE_TAG="0.${{ github.event.pull_request.number }}.${{ github.run_number }}"
fi
echo "Docker Image Tag: $DOCKER_IMAGE_TAG"
echo "DOCKER_IMAGE_TAG"="${DOCKER_IMAGE_TAG}" >> $GITHUB_OUTPUT
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build and push Docker image
env:
DOCKER_IMAGE_TAG: ${{ steps.set_docker_image_tag.outputs.DOCKER_IMAGE_TAG }}
run: |
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/techeerism-parser:$DOCKER_IMAGE_TAG .
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/techeerism-parser:$DOCKER_IMAGE_TAG
- name: Send Image and Version to Slack
if: github.ref == 'refs/heads/main' # main 브랜치에 머지 시에만 실행
env:
IMAGE_NAME: ${{ secrets.DOCKER_HUB_USERNAME }}/techeerism-parser
DOCKER_IMAGE_TAG: ${{ steps.set_docker_image_tag.outputs.DOCKER_IMAGE_TAG }}
SLACK_SECRET: ${{ secrets.SLACK_DEPLOY_SECRET }}
run: |
commit_message="${{ github.event.head_commit.message }}"
commit_link="https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/commit/${{ github.sha }}"
curl -X POST https://techeer-029051b54345.herokuapp.com/api/v1/deploy/image \
-H "Content-Type: application/json" \
-d '{
"imageName": "'"$IMAGE_NAME"'",
"imageTag": "'"$DOCKER_IMAGE_TAG"'",
"message": "'"$commit_message"'",
"commitLink": "'"$commit_link"'",
"secret": "'"$SLACK_SECRET"'"
}'
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN go mod download
COPY . .

# 고 바이너리 빌드 (arm64 아키텍처). amd64 아키텍처로 빌드하려면 GOARCH=amd64 로 변경
RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o crawler .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o crawler .

# 이미지 바이너리 빌드 할때 사용할 베이스 이미지. 가벼운 알파인 리눅스 사용
FROM alpine:latest
Expand Down

0 comments on commit 801f22c

Please sign in to comment.