Skip to content

Commit

Permalink
Add container image build and release job to GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
mfisher87 committed Jul 11, 2023
1 parent c133d1d commit 453b57e
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions .github/workflows/test-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
# instead?
push:
branches:
- "*"
- "main"
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
pull_request:
Expand Down Expand Up @@ -36,7 +36,6 @@ jobs:
- name: "Install Conda environment"
uses: "mamba-org/setup-micromamba@v1"
with:
micromamba-version: "1.4.2-2"
environment-file: "conda-lock.yml"
# When using a lock-file, we have to set an environment name.
environment-name: "qgreenland-ci"
Expand All @@ -63,9 +62,48 @@ 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/qgreenland"
IMAGE_TAG: "${{ github.ref_type == 'branch' && 'latest' || github.ref_name }}"
steps:
- name: "Check out repository"
uses: "actions/checkout@v3"

- 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 tag "${IMAGE_NAME}:${IMAGE_TAG}" "ghcr.io/${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"
Expand Down

0 comments on commit 453b57e

Please sign in to comment.