From ddd5ed9f22d7762c074b604ed39f8e9f4aeb751f Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Fri, 20 Mar 2020 16:14:32 -0500 Subject: [PATCH] ci: Use the same Docker workflow for testing as publication (#812) * Use the same Docker build workflow in testing as is used in publication to Docker Hub - Amends PR #808 * Use suggested () syntax as ${{ }} is ignored in 'if' statements - https://twitter.com/joshmgross/status/1241088248572776451 --- .github/workflows/ci.yml | 19 +++++++++++-------- .github/workflows/publish-docker.yml | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 852a671125..1358d1840f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -130,12 +130,15 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1.2.0 + - uses: actions/checkout@v2 - name: Build Docker image - run: | - docker build . \ - --file docker/Dockerfile \ - --build-arg BASE_IMAGE=python:3.7-slim \ - --tag pyhf/pyhf:$GITHUB_SHA \ - --compress - docker images + if: "!(startsWith(github.ref, 'refs/tags/'))" + uses: docker/build-push-action@v1 + with: + repository: pyhf/pyhf + dockerfile: docker/Dockerfile + tag_with_sha: true + tag_with_ref: true + push: false + - name: List built images + run: docker images diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index ce15f6a669..bcf5d27a16 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@master - name: Build and Publish to Registry - if: "! ${{ startsWith(github.ref, 'refs/tags/') }}" + if: "!(startsWith(github.ref, 'refs/tags/'))" uses: docker/build-push-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} @@ -24,7 +24,7 @@ jobs: dockerfile: docker/Dockerfile tags: latest - name: Build and Publish to Registry with Release Tag - if: ${{ startsWith(github.ref, 'refs/tags/') }} + if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }}