name: Build docker image and package for linux inputs: release-build: required: false description: "Whether to build the linux package in release mode. If set to '1', the package will be built in release mode. Otherwise, it will be built in development mode." build-unix-time: required: false description: "The unix time to use for building the linux package. The value should be a string representing the unix time in seconds." build-date: required: false description: "The date to use for building the linux package. The value should be a string representing the date in the format of 'YYYYMMDD'." check-3rd-api: required: false description: "Whether to run integration tests that call third party APIs. If set to '1', the tests will be run. Otherwise, the tests will be skipped." skip-tests: required: false description: "Whether to skip tests when building the linux package. If set to '1', the tests will be skipped. Otherwise, the tests will be run." platform: required: true description: "The platform to build the linux package for. The value should be in the format of 'os/arch[/variant]'. For example, 'linux/amd64', 'linux/arm64/v8', 'linux/arm/v7', or 'linux/arm/v6'." platform-name: required: true description: "The name of the platform to build the linux package for. The value should be a string that can be used in file names. For example, 'linux-amd64', 'linux-arm64', 'linux-armv7', or 'linux-armv6'." docker-push: required: true description: "Whether to push the built docker image to the registry. If set to 'true', the image will be pushed. Otherwise, it will not be pushed." docker-image-name: required: false description: "The repository name of the docker image to build. This is required if 'docker-push' is set to 'true'." docker-username: required: false description: "Username for logging in to the docker registry. This is required if 'docker-push' is set to 'true'." docker-password: required: false description: "Password for logging in to the docker registry. This is required if 'docker-push' is set to 'true'." docker-bake-meta-file-path: required: true description: "The file path to the docker bake meta file." docker-bake-meta-artifact-name: required: true description: "The name of the artifact that contains the docker bake meta file." docker-bake-digests-file-path: required: true description: "The file path to save the docker bake digests file. The file will be created with the name of the digest under this path." docker-bake-digests-artifact-name-prefix: required: true description: "The prefix for the docker bake digests artifact name." package-file-name-prefix: required: true description: "The prefix for the linux package file name." runs: using: "composite" steps: - name: Set up QEMU uses: docker/setup-qemu-action@v4 - name: Download docker bake meta artifact uses: actions/download-artifact@v8 with: name: ${{ inputs.docker-bake-meta-artifact-name }} path: ${{ runner.temp }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 - name: Login to DockerHub if: ${{ inputs.docker-username != '' && inputs.docker-password != '' }} uses: docker/login-action@v4 with: username: ${{ inputs.docker-username }} password: ${{ inputs.docker-password }} - name: Build docker for ${{ inputs.platform-name }} id: bake uses: docker/bake-action@v7 with: files: | ./docker-bake.hcl cwd://${{ inputs.docker-bake-meta-file-path }} source: . targets: image set: | *.tags=${{ inputs.docker-image-name }} *.platform=${{ inputs.platform }} *.args.RELEASE_BUILD=${{ inputs.release-build }} *.args.BUILD_PIPELINE=1 *.args.BUILD_UNIXTIME=${{ inputs.build-unix-time }} *.args.BUILD_DATE=${{ inputs.build-date }} *.args.CHECK_3RD_API=${{ inputs.check-3rd-api }} *.args.SKIP_TESTS=${{ inputs.skip-tests }} *.output=type=image,push-by-digest=true,name-canonical=true,push=${{ inputs.docker-push }} *.output+=type=local,dest=${{ runner.temp }}/package - name: Export digests file for ${{ inputs.platform-name }} shell: bash run: | digest="${{ fromJSON(steps.bake.outputs.metadata).image['containerimage.digest'] }}" mkdir -p ${{ inputs.docker-bake-digests-file-path }} touch "${{ inputs.docker-bake-digests-file-path }}/${digest#sha256:}" - name: Build package file for ${{ inputs.platform-name }} shell: bash run: | cd ${{ runner.temp }}/package/ezbookkeeping tar -czf ${{ runner.temp }}/${{ inputs.package-file-name-prefix }}-${{ inputs.platform-name }}.tar.gz * - name: Upload ${{ inputs.platform-name }} digests artifact uses: actions/upload-artifact@v7 with: name: ${{ inputs.docker-bake-digests-artifact-name-prefix }}-${{ inputs.platform-name }} path: ${{ inputs.docker-bake-digests-file-path }}/* if-no-files-found: error - name: Upload artifact for ${{ inputs.platform-name }} uses: actions/upload-artifact@v7 with: archive: false path: ${{ runner.temp }}/${{ inputs.package-file-name-prefix }}-${{ inputs.platform-name }}.tar.gz if-no-files-found: error