Update GitHub actions configuration (#548)

Update GitHub actions configuration (#548)

  • Only attempt dockerhub push if previous steps are successful
  • Make auto_build.rb exit with non-zero status if build fails
  • enable experimental features (–squash) for dev image build
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 888a0ea..4521508 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -11,7 +11,7 @@ jobs:
   base:
     runs-on: [ubuntu-20.04]
     steps:
-      - name: Setup Docker
+      - name: enable experimental docker features
         run: |
           sudo bash -c 'echo "{ \"cgroup-parent\": \"/actions_job\",\"experimental\":true}" > /etc/docker/daemon.json'
           sudo service docker restart
@@ -29,7 +29,7 @@ jobs:
         run: |
           docker run --rm -e RUBY_ONLY=1 -e USE_TURBO=1 -e SKIP_PLUGINS=1 -e SKIP_LINT=1 discourse/discourse_test:build
       - name: push to dockerhub
-        if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
+        if: success() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
         env:
           DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
         run: |
@@ -43,14 +43,19 @@ jobs:
     runs-on: [ubuntu-20.04]
     needs: base
     steps:
+      - name: enable experimental docker features
+        run: |
+          sudo bash -c 'echo "{ \"cgroup-parent\": \"/actions_job\",\"experimental\":true}" > /etc/docker/daemon.json'
+          sudo service docker restart
+          docker version -f '{{.Server.Experimental}}'
       - uses: actions/checkout@master
         with:
           fetch-depth: 1
-      - name: build test_build image
+      - name: build discourse_test image
         run: |
           cd image && ruby auto_build.rb discourse_test_public
       - name: push to dockerhub
-        if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
+        if: success() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
         env:
           DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
         run: |
@@ -63,11 +68,11 @@ jobs:
       - uses: actions/checkout@master
         with:
           fetch-depth: 1
-      - name: build test_build image
+      - name: build discourse_dev image
         run: |
           cd image && ruby auto_build.rb discourse_dev
       - name: push to dockerhub
-        if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
+        if: success() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
         env:
           DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
         run: |
diff --git a/image/auto_build.rb b/image/auto_build.rb
index 70415db..814f86e 100644
--- a/image/auto_build.rb
+++ b/image/auto_build.rb
@@ -21,8 +21,11 @@ def run(command)
     rescue Errno::EIO
       # we are done
     end
+    Process.wait(pid)
   end
 
+  raise "'#{command}' exited with status #{$?.exitstatus}" if $?.exitstatus != 0
+
   lines
 end
 

GitHub sha: 03d5606521bcc4147066d2d89ab20581d1d227fe

This commit appears in #548 which was approved by CvX. It was merged by davidtaylorhq.