|
| 1 | +name: Build ASYNC NATIVE |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + |
| 9 | +env: |
| 10 | + DOCKER_HUB_IMAGE_NAME: "amd64-arm64" |
| 11 | + |
| 12 | +jobs: |
| 13 | + compute_tags: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + #https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/passing-information-between-jobs |
| 16 | + outputs: |
| 17 | + tag_latest: ${{ steps.compute-tags.outputs.tag_latest }} |
| 18 | + tag_version: ${{ steps.compute-tags.outputs.tag_version }} |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v3 |
| 22 | + |
| 23 | + - name: Compute tags |
| 24 | + id: compute-tags |
| 25 | + run: | |
| 26 | + PACKAGE_VERSION=$(cat package.json | jq -r '.version') |
| 27 | + DOCKER_HUB_TAG_BASE=async/${DOCKER_HUB_IMAGE_NAME}:${{github.ref_name}} |
| 28 | + DOCKER_HUB_TAG_LATEST=${DOCKER_HUB_TAG_BASE}-latest |
| 29 | + if [ "${{github.ref_name}}" = "prod" ]; then |
| 30 | + DOCKER_HUB_TAG_VERSION=${DOCKER_HUB_TAG_BASE}-${PACKAGE_VERSION} |
| 31 | + else |
| 32 | + DOCKER_HUB_TAG_VERSION="" |
| 33 | + fi |
| 34 | + echo "tag_latest=${DOCKER_HUB_TAG_LATEST}" >> $GITHUB_OUTPUT |
| 35 | + echo "tag_version=${DOCKER_HUB_TAG_VERSION}" >> $GITHUB_OUTPUT |
| 36 | +
|
| 37 | + build_amd64: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + needs: [compute_tags] |
| 40 | + steps: |
| 41 | + - name: Checkout |
| 42 | + uses: actions/checkout@v3 |
| 43 | + |
| 44 | + - name: Set up Docker Buildx |
| 45 | + uses: docker/setup-buildx-action@v3 |
| 46 | + |
| 47 | + - name: Build amd64 |
| 48 | + run: | |
| 49 | + echo "AMD64 Got value latest: ${{ needs.compute_tags.outputs.tag_latest }}" |
| 50 | + echo "AMD64 Got value version: ${{ needs.compute_tags.outputs.tag_version }}" |
| 51 | +
|
| 52 | + - name: Build image amd64 |
| 53 | + uses: docker/build-push-action@v5 |
| 54 | + with: |
| 55 | + context: . |
| 56 | + platforms: linux/amd64 |
| 57 | + push: false |
| 58 | + tags: | |
| 59 | + ${{ needs.compute_tags.outputs.tag_latest }} |
| 60 | + ${{ needs.compute_tags.outputs.tag_version }} |
| 61 | +
|
| 62 | + build_arm64: |
| 63 | + runs-on: ubuntu-latest |
| 64 | + needs: [compute_tags] |
| 65 | + steps: |
| 66 | + - name: Checkout |
| 67 | + uses: actions/checkout@v3 |
| 68 | + |
| 69 | + - name: Set up Docker Buildx |
| 70 | + uses: docker/setup-buildx-action@v3 |
| 71 | + |
| 72 | + - name: Build arm64 |
| 73 | + run: | |
| 74 | + echo "ARM64 Got value latest: ${{ needs.compute_tags.outputs.tag_latest }}" |
| 75 | + echo "ARM64 Got value version: ${{ needs.compute_tags.outputs.tag_version }}" |
| 76 | +
|
| 77 | + #Build and push docker image |
| 78 | + - name: Build and push image arm64 |
| 79 | + uses: docker/build-push-action@v5 |
| 80 | + with: |
| 81 | + context: ./Dockerfile.arm |
| 82 | + platforms: linux/arm64 |
| 83 | + push: false |
| 84 | + tags: | |
| 85 | + ${{ needs.compute_tags.outputs.tag_latest }} |
| 86 | + ${{ needs.compute_tags.outputs.tag_version }} |
| 87 | +
|
| 88 | + merge_amd64_and-amr64: |
| 89 | + runs-on: ubuntu-latest |
| 90 | + needs: [build_amd64, build_arm64] |
| 91 | + run: | |
| 92 | + echo "so two previous build should push to :arm & :amd tag, then now we are going to merge them to one" |
| 93 | + echo "docker manifest create yourdockerhubusername/yourimage:latest \nyourdockerhubusername/yourimage:amd \nyourdockerhubusername/yourimage:arm \n docker manifest push yourdockerhubusername/yourimage:latest" |
0 commit comments