-Service- Search #7
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
name: -Service- Search | |
on: | |
workflow_dispatch | |
jobs: | |
build-and-deploy-search-service: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21.x' | |
- name: Download dependencies | |
run: cd search-esdb-service && go mod download && go mod vendor | |
- name: Build | |
run: cd search-esdb-service && env GOOS=linux CGO_ENABLED=0 go build -o searchApp . | |
- name: Set up Docker | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./search-esdb-service | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/dhammanava-search-image:latest | |
- name: Deploy to Ubuntu server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{secrets.LINUX_HOST}} | |
username: ${{secrets.LINUX_USERNAME}} | |
key: ${{ secrets.LINUX_PRIVATE_KEY }} | |
script: | | |
docker stop search-container || true | |
docker rm search-container || true | |
docker image rm ${{ secrets.DOCKERHUB_USERNAME }}/dhammanava-search-image:latest | |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/dhammanava-search-image:latest | |
cd dhammanava-search | |
docker compose -f docker-compose.prod.yml up -d search-service |