From 531807fbf8e565bf29fd8c56fbcee2102646127c Mon Sep 17 00:00:00 2001 From: Matt Fisher Date: Mon, 10 Jul 2023 20:36:50 -0600 Subject: [PATCH] Add container image build and release job to GHA --- .github/workflows/test-and-build.yml | 36 +++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml index 04791f53..b8c920d2 100644 --- a/.github/workflows/test-and-build.yml +++ b/.github/workflows/test-and-build.yml @@ -63,9 +63,43 @@ jobs: QT_QPA_PLATFORM: offscreen - build: + # TODO: Consider extracting everything below this line to a separate workflow + # which is triggered by pushes to the default branch and GitHub releases. + build-and-release-image: runs-on: "ubuntu-latest" needs: ["test"] + # if: "github.ref_type == 'tag' || github.ref == github.event.repository.default_branch" + if: "github.ref_type == 'tag' || github.ref_type = 'branch'" + env: + IMAGE_NAME: "nsidc/noaa-web-server" + IMAGE_TAG: "${{ github.ref_type == 'branch' && 'latest' || github.ref_name }}" + steps: + - name: "Build Docker image" + run: | + docker build -t "${IMAGE_NAME}:${IMAGE_TAG}" . + + - name: "DockerHub login" + uses: "docker/login-action@v2" + with: + username: "${{secrets.DOCKER_USER}}" + password: "${{secrets.DOCKER_PASS}}" + + - name: "GHCR login" + uses: "docker/login-action@v2" + with: + registry: "ghcr.io" + username: "${{ github.repository_owner }}" + password: "${{ secrets.GITHUB_TOKEN }}" + + - name: "Release to DockerHub and GHCR" + run: | + docker push "${IMAGE_NAME}:${IMAGE_TAG}" + docker push "ghcr.io/${IMAGE_NAME}:${IMAGE_TAG}" + + + build-package: + runs-on: "ubuntu-latest" + needs: ["build-and-release-image"] if: "github.ref_type == 'tag'" steps: - name: "Trigger Jenkins to build QGreenland Core"