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 a983fe4 commit 531807f
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion .github/workflows/test-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 531807f

Please sign in to comment.