From 6541f9ff31dbf36e283eac95930af6a029e46763 Mon Sep 17 00:00:00 2001
From: "Glenn Y. Rolland" <glenux@glenux.net>
Date: Tue, 21 Dec 2021 16:03:29 +0100
Subject: [PATCH] ci: fix artifact file name

---
 .github/workflows/build-and-publish.yml | 31 +++++++++++--------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml
index cb0ebb5..cafdbc9 100644
--- a/.github/workflows/build-and-publish.yml
+++ b/.github/workflows/build-and-publish.yml
@@ -1,16 +1,14 @@
 ---
 name: "Build, Test and Publish"
 
-on:
+"on":
   # run it on push to the default repository branch
   push:
-    branches: [master]
+    branches: [master, develop]
   # run it during pull request
   pull_request:
 
 jobs:
-  # define job to build and publish docker image
-
   build-docker-image:
     name: "Build docker image"
     # run only when code is compiling and tests are passing
@@ -79,7 +77,7 @@ jobs:
 
       - name: Load image
         run: |
-          docker load --input /tmp/myimage.tar
+          docker load --input /tmp/teaching-boilerplate.image.tar
           docker image ls -a
 
       - name: Build HTML for docs
@@ -95,8 +93,9 @@ jobs:
         run: ./scripts/gx-teaching . build-slides-pdf
 
   push-docker-image:
-    needs: test-docker-image
     name: "Push docker image to registry"
+    needs: test-docker-image
+    if: github.ref == 'refs/heads/master'
     runs-on: ubuntu-latest
     steps:
       - name: Download artifact
@@ -124,18 +123,14 @@ jobs:
           username: ${{ secrets.DOCKERHUB_USERNAME }}
           password: ${{ secrets.DOCKERHUB_TOKEN }}
 
-      - name: Build image and push to Docker Hub and GitHub Container Registry
-        uses: docker/build-push-action@v2
-        with:
-          # relative path to the place where source code with Dockerfile
-          # is located
-          context: .
-          file: docker/Dockerfile
-          # Note: tags has to be all lower-case
-          tags: |
-            glenux/teaching-boilerplate:${{ env.BUILD_VERSION }}
+      - name: Tag images
+        run: >
+          docker tag
             glenux/teaching-boilerplate:latest
-          # build on feature branches, push only on main branch
-          push: ${{ github.ref == 'refs/heads/master' }}
+            glenux/teaching-boilerplate:${{ env.BUILD_VERSION }}
 
+      - name: Build image and push to Docker Hub and GitHub Container Registry
+        run: |
+          docker push glenux/teaching-boilerplate:latest
+          docker push glenux/teaching-boilerplate:${{ env.BUILD_VERSION }}
 #