Merge pull request #19 from OpenPecha/searchapi #66
This file contains hidden or 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: agent-microservice | |
| on: [push, pull_request, workflow_dispatch] | |
| jobs: | |
| buildDockerImage: | |
| name: Build and Dockerize | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image_name: ${{ steps.set-tag.outputs.image_name }} | |
| image_tag: ${{ steps.set-tag.outputs.image_tag }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.ADMIN_GITHUB_TOKEN }} | |
| - name: Set image name and tag | |
| id: set-tag | |
| run: | | |
| echo "IMAGE_NAME=agent-microservice" >> $GITHUB_ENV | |
| echo "image_name=agent-microservice" >> $GITHUB_OUTPUT | |
| if [[ -n "${{ github.ref }}" && "${{ github.ref }}" =~ ^refs/tags/ ]]; then | |
| tagNumber=$(echo "${{ github.ref }}" | sed 's#refs/tags/##') | |
| echo "IMAGE_TAG=$tagNumber" >> $GITHUB_ENV | |
| echo "image_tag=$tagNumber" >> $GITHUB_OUTPUT | |
| else | |
| calculatedSha=$(git rev-parse --short ${{ github.sha }}) | |
| tagNumber=${{ github.run_id }}-$calculatedSha | |
| echo "IMAGE_TAG=$tagNumber" >> $GITHUB_ENV | |
| echo "image_tag=$tagNumber" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Confirm image name and tag | |
| run: | | |
| echo "Image Name: ${{ env.IMAGE_NAME }}" | |
| echo "Image Tag: ${{ env.IMAGE_TAG }}" | |
| - name: Build Docker image in Github container registry | |
| run: | | |
| lower_owner=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]') | |
| docker build -t ghcr.io/$lower_owner/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} . | |
| - name: Push Docker image to GHCR | |
| run: | | |
| lower_owner=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]') | |
| docker push ghcr.io/$lower_owner/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} |