build-hadoop-image.yaml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. name: build-hadoop-image
  16. # This workflow builds the Hadoop docker image.
  17. # For non-PR runs, it also pushes the image to the registry, tagging it based on the branch name.
  18. on:
  19. pull_request:
  20. types: [opened, synchronize]
  21. branches:
  22. - 'docker-hadoop-**'
  23. - '!docker-hadoop-runner-**'
  24. push:
  25. branches:
  26. - 'docker-hadoop-**'
  27. - '!docker-hadoop-runner-**'
  28. permissions:
  29. contents: read
  30. packages: write
  31. jobs:
  32. build:
  33. runs-on: ubuntu-latest
  34. steps:
  35. - name: Generate image ID
  36. id: meta
  37. uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
  38. with:
  39. images: |
  40. ghcr.io/${{ github.repository_owner }}/hadoop
  41. tags: |
  42. type=match,pattern=docker-hadoop-(.*),value={{branch}},group=1
  43. flavor: |
  44. latest=false
  45. - name: Login to ghcr.io
  46. id: login
  47. if: ${{ github.event_name != 'pull_request' }}
  48. uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
  49. with:
  50. registry: ghcr.io
  51. username: ${{ github.repository_owner }}
  52. password: ${{ secrets.GITHUB_TOKEN }}
  53. - name: Build and push image
  54. id: build
  55. uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75
  56. with:
  57. platforms: linux/amd64
  58. push: ${{ github.event_name != 'pull_request' }}
  59. tags: ${{ steps.meta.outputs.tags }}
  60. labels: ${{ steps.meta.outputs.labels }}