Skip to content

Build and push mags_vis container image to GHCR #11

Build and push mags_vis container image to GHCR

Build and push mags_vis container image to GHCR #11

name: Build and push mags_vis container image to GHCR
# Run this workflow whenever a Dockerfile is updated.
on:
workflow_dispatch:
push:
branches:
- Docker
paths:
- 'Docker/Dockerfile_vis'
jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: Docker
- name: Get Version
id: get_version
run: |
VERSION=$(grep "version=" Docker/Dockerfile_vis | cut -d"=" -f 2 | sed -e 's/\"//g')
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Authenticate with container registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Use the `docker/build-push-action` action to build the image described
# by the specified Dockerfile. If the build succeeds, push the image to GHCR.
# This action uses the `tags` parameters to tag the image with the Git tag name
# the image, respectively, with the output from the "get_version" step above.
# For more info: https://github.com/docker/build-push-action#usage.
- name: Build and push container image
id: push
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
context: .
file: Docker/Dockerfile_vis
push: true
tags: ghcr.io/microbiomedata/nmdc-mbin_vis:${{ steps.get_version.outputs.version }}
# References:
# - https://docs.github.com/en/actions/learn-github-actions/variables#using-the-vars-context-to-access-configuration-variable-values
# - https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages
# - https://github.com/microbiomedata/nmdc-edge/blob/main/.github/workflows/build-and-push-image.yml
# - https://stackoverflow.com/questions/59191913/how-do-i-get-the-output-of-a-specific-step-in-github-actions