name: Build and Push Docker Image on: push: branches: [ main ] pull_request: branches: [ main ] env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} IMAGE_TAG: ${{ github.sha }} jobs: build-and-push: runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v4 - name: Log in to the Container registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . file: container/Dockerfile push: ${{ github.event_name != 'pull_request' }} tags: ${{ env.REGISTRY }}/saya-search:${{ env.IMAGE_TAG }}