Browse Source

Remove qemu, run job only if shasum does not exists

Anuj Bansal 3 years ago
parent
commit
8fd75e4d71
2 changed files with 15 additions and 16 deletions
  1. 13 15
      .github/workflows/joystream-node-docker.yml
  2. 2 1
      scripts/runtime-code-shasum.sh

+ 13 - 15
.github/workflows/joystream-node-docker.yml

@@ -12,7 +12,7 @@ jobs:
     runs-on: ubuntu-latest
     outputs:
       tag_shasum: ${{ steps.compute_shasum.outputs.shasum }}
-      image_exists: ${{ steps.compute_image_exists.outputs.image_exists }}
+      image_exists: ${{ steps.compute_main_image_exists.outputs.image_exists }}
     steps:
       - name: Checkout
         uses: actions/checkout@v2
@@ -21,12 +21,6 @@ jobs:
         with:
           node-version: '14.x'
 
-      - name: Set up QEMU
-        uses: docker/setup-qemu-action@v1
-
-      - name: Set up Docker Buildx
-        uses: docker/setup-buildx-action@v1
-
       - id: compute_shasum
         name: Compute runtime code shasum
         run: |
@@ -39,6 +33,13 @@ jobs:
           username: ${{ secrets.DOCKERHUB_USERNAME }}
           password: ${{ secrets.DOCKERHUB_PASSWORD }}
 
+      - name: Check if we have already have the manifest on Dockerhub
+        id: compute_main_image_exists
+        # Will output 0 if image exists and 1 if does not exists
+        run: |
+          export IMAGE_EXISTS=$(docker manifest inspect ${{ env.REPOSITORY }}:${{ steps.compute_shasum.outputs.shasum }} > /dev/null ; echo $?)
+          echo "::set-output name=image_exists::${IMAGE_EXISTS}"
+
       - name: Check if we have pre-built image on Dockerhub
         id: compute_image_exists
         # Will output 0 if image exists and 1 if does not exists
@@ -59,11 +60,6 @@ jobs:
   push-arm:
     name: Build joystream/node Docker image for arm
     runs-on: ubuntu-latest
-    env:
-      STACK_NAME: joystream-ga-docker-${{ github.run_number }}
-    outputs:
-      image_exists_arm64: ${{ steps.compute_image_exists.outputs.image_exists_arm64 }}
-      image_exists_arm: ${{ steps.compute_image_exists.outputs.image_exists_arm }}
     strategy:
       matrix:
         platform: ['linux/arm64', 'linux/arm/v7']
@@ -74,6 +70,8 @@ jobs:
           - platform: 'linux/arm/v7'
             platform_tag: 'arm'
             file: 'joystream-node-armv7.Dockerfile'
+    env:
+      STACK_NAME: joystream-ga-docker-${{ github.run_number }}-${{ matrix.platform_tag }}
     steps:
       - name: Extract branch name
         shell: bash
@@ -107,7 +105,6 @@ jobs:
         # Will output 0 if image exists and 1 if does not exists
         run: |
           export IMAGE_EXISTS=$(docker manifest inspect ${{ env.REPOSITORY }}:${{ steps.compute_shasum.outputs.shasum }}-${{ matrix.platform_tag }} > /dev/null ; echo $?)
-          echo "::set-output name=image_exists_${{ matrix.platform_tag }}::${IMAGE_EXISTS}"
           echo "::set-output name=image_exists::${IMAGE_EXISTS}"
 
       - name: Configure AWS credentials
@@ -122,7 +119,7 @@ jobs:
         uses: aws-actions/aws-cloudformation-github-deploy@v1
         id: deploy_stack
         with:
-          name: '${{ env.STACK_NAME }}-${{ matrix.platform_tag }}'
+          name: ${{ env.STACK_NAME }}
           template: devops/infrastructure/single-instance-docker.yml
           no-fail-on-empty-changeset: '1'
           parameter-overrides: 'KeyName=${{ env.KEY_NAME }},EC2AMI=ami-00d1ab6b335f217cf,EC2InstanceType=t4g.xlarge'
@@ -151,7 +148,8 @@ jobs:
   push-manifest:
     name: Create manifest using both the arch images
     needs: [push-amd64, push-arm]
-    if: needs.push-amd64.outputs.image_exists == 1 || needs.push-arm.outputs.image_exists_arm == 1 || needs.push-arm.outputs.image_exists_arm64 == 1
+    # Only run this job if the image does not exist with tag equal to the shasum
+    if: needs.push-amd64.outputs.image_exists == 1
     runs-on: ubuntu-latest
     env:
       TAG_SHASUM: ${{ needs.push-amd64.outputs.tag_shasum }}

+ 2 - 1
scripts/runtime-code-shasum.sh

@@ -19,4 +19,5 @@ ${TAR} -c --sort=name --owner=root:0 --group=root:0 --mode 644 --mtime='UTC 2020
     runtime \
     runtime-modules \
     utils/chain-spec-builder \
-    joystream-node.Dockerfile | shasum | cut -d " " -f 1
+    joystream-node.Dockerfile \
+    joystream-node-armv7.Dockerfile | shasum | cut -d " " -f 1