reusable-app-build-image.yml 2.7 KB

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