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 66b5b77
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 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,46 @@ 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: "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 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 66b5b77

Please sign in to comment.