build_docker_parser.yaml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. name: "[searcher] build container image"
  2. on:
  3. push:
  4. branches: ["main"]
  5. tags: ["v*.*.*"]
  6. pull_request:
  7. branches: ["main"]
  8. env:
  9. REGISTRY: ghcr.io
  10. IMAGE_NAME: ${{ github.repository }}
  11. jobs:
  12. build:
  13. runs-on: ubuntu-latest
  14. permissions:
  15. contents: read
  16. packages: write
  17. id-token: write
  18. steps:
  19. - name: Checkout repository
  20. uses: actions/checkout@v3
  21. - name: Setup Docker buildx
  22. uses: docker/setup-buildx-action@v2.9.1
  23. - name: Log into registry ${{ env.REGISTRY }}
  24. if: github.event_name != 'pull_request'
  25. uses: docker/login-action@v2.2.0
  26. with:
  27. registry: ${{ env.REGISTRY }}
  28. username: ${{ github.actor }}
  29. password: ${{ secrets.GITHUB_TOKEN }}
  30. - name: Extract Docker metadata
  31. id: meta
  32. uses: docker/metadata-action@v4.6.0
  33. with:
  34. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  35. tags: |
  36. type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
  37. type=semver,pattern={{version}}
  38. - name: Build and push Docker image
  39. id: build-and-push
  40. uses: docker/build-push-action@v4.1.1
  41. with:
  42. context: ./searcher
  43. push: ${{ github.event_name != 'pull_request' }}
  44. tags: ${{ steps.meta.outputs.tags }}
  45. labels: ${{ steps.meta.outputs.labels }}
  46. cache-from: type=gha
  47. cache-to: type=gha,mode=max