From 3c553897d6616d390e7874a363306bee5e1442d2 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Thu, 20 Jan 2022 07:13:05 -0700 Subject: [PATCH] Per #1546, changed build docker script to use Dockerfile.copy to use local source code, set environment variables that set docker build args in workflow yml --- .github/jobs/build_docker_image.sh | 21 ++++++------------ .../build_docker_and_trigger_metplus.yml | 3 +++ .github/workflows/test_compilation.yml | 22 +++++++++++++++++++ 3 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/test_compilation.yml diff --git a/.github/jobs/build_docker_image.sh b/.github/jobs/build_docker_image.sh index 92f2bedb4d..ab438ff016 100755 --- a/.github/jobs/build_docker_image.sh +++ b/.github/jobs/build_docker_image.sh @@ -2,20 +2,13 @@ source ${GITHUB_WORKSPACE}/.github/jobs/bash_functions.sh - local duration=$(( SECONDS - start_seconds )) - echo "TIMING: Command took `printf '%02d' $(($duration / 60))`:`printf '%02d' $(($duration % 60))` (MM:SS): '$*'" - if [ ${error} -ne 0 ]; then - echo "ERROR: '$*' exited with status = ${error}" - fi - return $error -} +#prefix=refs/heads/ +#branch_name=${GITHUB_REF#"$prefix"} +DOCKERHUB_TAG=dtcenter/met:${SOURCE_BRANCH} -prefix=refs/heads/ -branch_name=${GITHUB_REF#"$prefix"} -DOCKERHUB_TAG=dtcenter/met:${branch_name} - -DOCKERFILE_DIR=${GITHUB_WORKSPACE}/scripts/docker +DOCKERFILE_PATH=${GITHUB_WORKSPACE}/scripts/docker/Dockerfile.copy time_command docker build -t ${DOCKERHUB_TAG} \ - --build-arg SOURCE_BRANCH=$branch_name \ - $DOCKERFILE_DIR + --build-arg SOURCE_BRANCH \ + --build-arg MET_BASE_IMAGE \ + -f $DOCKERFILE_PATH ${GITHUB_WORKSPACE} diff --git a/.github/workflows/build_docker_and_trigger_metplus.yml b/.github/workflows/build_docker_and_trigger_metplus.yml index 064fce870b..2ed61df747 100644 --- a/.github/workflows/build_docker_and_trigger_metplus.yml +++ b/.github/workflows/build_docker_and_trigger_metplus.yml @@ -17,6 +17,9 @@ jobs: - name: Build Docker Image run: .github/jobs/build_docker_image.sh + env: + SOURCE_BRANCH: ${GITHUB_REF#"refs/heads/"} + MET_BASE_IMAGE: minimum - name: Push Docker Image run: .github/jobs/push_docker_image.sh diff --git a/.github/workflows/test_compilation.yml b/.github/workflows/test_compilation.yml new file mode 100644 index 0000000000..563c7284fe --- /dev/null +++ b/.github/workflows/test_compilation.yml @@ -0,0 +1,22 @@ +name: Compilation Test + +on: + push: + branches: + - feature_1546_ci_testing + paths-ignore: + - 'met/docs/**' + +jobs: + + build_met_docker: + name: Handle Docker Image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Build Docker Image + run: .github/jobs/build_docker_image.sh + env: + SOURCE_BRANCH: ${GITHUB_REF#"refs/heads/"} + MET_BASE_IMAGE: minimum