Merge pull request #29 from nsidc/nsidc-demo-slides #36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Build and publish container image" | |
on: | |
push: | |
branches: | |
- "main" | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+*" | |
jobs: | |
build-and-release-api-image: | |
name: "Build and release API container image" | |
runs-on: "ubuntu-latest" | |
env: | |
IMAGE_NAME: "data-access-tool-api" | |
# GitHub Actions expressions don't have great conditional support, so | |
# writing a ternary expression looks a lot like bash. In Python, this | |
# would read as: | |
# github.ref_name if github.ref_type == 'tag' else 'latest' | |
# https://docs.github.com/en/actions/learn-github-actions/expressions | |
IMAGE_TAG: | |
"${{ github.ref_type == 'tag' && github.ref_name || 'latest' }}" | |
steps: | |
- name: "Check out repository" | |
uses: "actions/checkout@v4" | |
- name: "Build container image" | |
run: | | |
docker build --tag "ghcr.io/nsidc/${IMAGE_NAME}:${IMAGE_TAG}" . | |
- name: "GHCR login" | |
uses: "docker/login-action@v3" | |
with: | |
registry: "ghcr.io" | |
username: "${{ github.repository_owner }}" | |
password: "${{ secrets.GITHUB_TOKEN }}" | |
- name: "Push to image registries (DockerHub, GHCR)" | |
run: | | |
# Push to GHCR | |
docker push "ghcr.io/nsidc/${IMAGE_NAME}:${IMAGE_TAG}" |