build_docker_parser.yaml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 Builder image
  39. id: build-and-push-cache
  40. uses: docker/build-push-action@v4.1.1
  41. with:
  42. context: ./searcher
  43. push: false
  44. tags: ${{ steps.meta.outputs.tags }}
  45. labels: ${{ steps.meta.outputs.labels }}
  46. target: builder
  47. cache-from: type=gha
  48. cache-to: type=gha,mode=max
  49. - name: Build and push Docker Main image
  50. id: build-and-push
  51. uses: docker/build-push-action@v4.1.1
  52. with:
  53. context: ./searcher
  54. push: ${{ github.event_name != 'pull_request' }}
  55. tags: ${{ steps.meta.outputs.tags }}
  56. labels: ${{ steps.meta.outputs.labels }}
  57. cache-from: type=gha