build: test iteration #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build ASYNC NATIVE | ||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: | ||
| - master | ||
| env: | ||
| DOCKER_HUB_IMAGE_NAME: "amd64-arm64" | ||
| jobs: | ||
| compute_tags: | ||
| runs-on: ubuntu-latest | ||
| #https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/passing-information-between-jobs | ||
| outputs: | ||
| tag_latest: ${{ steps.compute-tags.outputs.tag_latest }} | ||
| tag_version: ${{ steps.compute-tags.outputs.tag_version }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v3 | ||
| - name: Compute tags | ||
| id: compute-tags | ||
| run: | | ||
| PACKAGE_VERSION=$(cat package.json | jq -r '.version') | ||
| DOCKER_HUB_TAG_BASE=async/${DOCKER_HUB_IMAGE_NAME}:${{github.ref_name}} | ||
| DOCKER_HUB_TAG_LATEST=${DOCKER_HUB_TAG_BASE}-latest | ||
| if [ "${{github.ref_name}}" = "prod" ]; then | ||
| DOCKER_HUB_TAG_VERSION=${DOCKER_HUB_TAG_BASE}-${PACKAGE_VERSION} | ||
| else | ||
| DOCKER_HUB_TAG_VERSION="" | ||
| fi | ||
| echo "tag_latest=${DOCKER_HUB_TAG_LATEST}" >> $GITHUB_OUTPUT | ||
| echo "tag_version=${DOCKER_HUB_TAG_VERSION}" >> $GITHUB_OUTPUT | ||
| build_amd64: | ||
| runs-on: ubuntu-latest | ||
| needs: [compute_tags] | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v3 | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| - name: Build amd64 | ||
| run: | | ||
| echo "AMD64 Got value latest: ${{ needs.compute_tags.outputs.tag_latest }}" | ||
| echo "AMD64 Got value version: ${{ needs.compute_tags.outputs.tag_version }}" | ||
| - name: Build image amd64 | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| platforms: linux/amd64 | ||
| push: false | ||
| tags: | | ||
| ${{ needs.compute_tags.outputs.tag_latest }} | ||
| ${{ needs.compute_tags.outputs.tag_version }} | ||
| build_arm64: | ||
| runs-on: ubuntu-latest | ||
| needs: [compute_tags] | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v3 | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| - name: Build arm64 | ||
| run: | | ||
| echo "ARM64 Got value latest: ${{ needs.compute_tags.outputs.tag_latest }}" | ||
| echo "ARM64 Got value version: ${{ needs.compute_tags.outputs.tag_version }}" | ||
| #Build and push docker image | ||
| - name: Build and push image arm64 | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: ./Dockerfile.arm | ||
| platforms: linux/arm64 | ||
| push: false | ||
| tags: | | ||
| ${{ needs.compute_tags.outputs.tag_latest }} | ||
| ${{ needs.compute_tags.outputs.tag_version }} | ||
| merge_amd64_and-amr64: | ||
| runs-on: ubuntu-latest | ||
| needs: [build_amd64, build_arm64] | ||
| steps: | ||
| run: | | ||
| echo "so two previous build should push to :arm & :amd tag, then now we are going to merge them to one" | ||
| echo "docker manifest create yourdockerhubusername/yourimage:latest \nyourdockerhubusername/yourimage:amd \nyourdockerhubusername/yourimage:arm \n docker manifest push yourdockerhubusername/yourimage:latest" | ||