reusable-app-build-image.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. name: Reusable build app container image workflow
  2. on:
  3. workflow_call:
  4. inputs:
  5. tags:
  6. type: string
  7. required: true
  8. image-name:
  9. type: string
  10. default: weseek/growi
  11. tag-temporary:
  12. type: string
  13. default: latest
  14. secrets:
  15. AWS_ROLE_TO_ASSUME_FOR_OIDC:
  16. required: true
  17. DOCKER_REGISTRY_PASSWORD:
  18. required: true
  19. DOCKER_REGISTRY_ON_GITHUB_PASSWORD:
  20. required: true
  21. jobs:
  22. build-image:
  23. runs-on: ubuntu-latest
  24. # These permissions are needed to interact with GitHub's OIDC Token endpoint.
  25. permissions:
  26. id-token: write
  27. contents: write
  28. strategy:
  29. matrix:
  30. platform: [amd64, arm64]
  31. steps:
  32. - uses: actions/checkout@v3
  33. - name: Configure AWS Credentials
  34. uses: aws-actions/configure-aws-credentials@v1
  35. with:
  36. aws-region: ap-northeast-1
  37. role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_FOR_OIDC }}
  38. role-session-name: SessionForReleaseGROWI-RC
  39. - name: Run CodeBuild
  40. uses: aws-actions/aws-codebuild-run-build@v1
  41. with:
  42. project-name: growi-official-image-builder
  43. image-override: ${{ (matrix.platform == 'amd64' && 'aws/codebuild/standard:6.0') || 'aws/codebuild/amazonlinux2-aarch64-standard:2.0' }}
  44. environment-type-override: ${{ (matrix.platform == 'amd64' && 'LINUX_CONTAINER') || 'ARM_CONTAINER' }}
  45. env-vars-for-codebuild: |
  46. IMAGE_TAG,
  47. IMAGE_TAG_GHCR
  48. env:
  49. IMAGE_TAG: docker.io/${{ inputs.image-name }}:${{ inputs.tag-temporary }}-${{ matrix.platform }}
  50. IMAGE_TAG_GHCR: ghcr.io/${{ inputs.image-name }}:${{ inputs.tag-temporary }}-${{ matrix.platform }}
  51. create-manifest:
  52. needs: [build-image]
  53. runs-on: ubuntu-latest
  54. strategy:
  55. matrix:
  56. registry: [docker.io, ghcr.io]
  57. steps:
  58. - uses: actions/checkout@v3
  59. - name: Retrieve information from package.json
  60. uses: myrotvorets/info-from-package-json-action@1.2.0
  61. id: package-json
  62. - name: Docker meta for extra-images
  63. id: meta-extra-images
  64. uses: docker/metadata-action@v4
  65. with:
  66. images: ${{ matrix.registry }}/${{ inputs.image-name }}
  67. sep-tags: ','
  68. tags: |
  69. type=raw,value=${{ inputs.tag-temporary }}-amd64
  70. type=raw,value=${{ inputs.tag-temporary }}-arm64
  71. - name: Login to Container Registry
  72. uses: docker/login-action@v2
  73. with:
  74. registry: ${{ matrix.registry }}
  75. username: wsmoogle
  76. password: ${{ (startsWith(matrix.registry, 'docker') && secrets.DOCKER_REGISTRY_PASSWORD) || secrets.DOCKER_REGISTRY_ON_GITHUB_PASSWORD }}
  77. - name: Create and push manifest images for ${{ matrix.registry }}
  78. uses: Noelware/docker-manifest-action@master
  79. with:
  80. base-image: ${{ inputs.tags }}
  81. extra-images: ${{ steps.meta-extra-images.outputs.tags }}
  82. push: true