Add github action for build/push images #1
This file contains 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
# Build and publish container images | |
# | |
# There are three images in this repo we want to build and publish individually: | |
# - GISPy | |
# - ISIS | |
# - ASP | |
# | |
# The images should be tagged as 'latest' and "$VERSION", where the version | |
# will point unequivocally to a git commit/tag of this repo. | |
# 'latest' will be the latest version of repository in 'stable' branch. | |
# | |
# Reference docs: | |
# - docs.github.com/en/actions/publishing-packages/publishing-docker-images | |
name: Build and Publish Containers | |
# Controls when the action will run. Triggers the workflow on push request, or repository dispatch | |
on: | |
# Runs when pushing to 'stable' branch | |
push: | |
branches: | |
- 'stable' | |
- 'test' | |
tags: | |
- 'v*' | |
# Run in every PR too | |
pull_request: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- # https://github.com/marketplace/actions/checkout | |
name: Checkout | |
uses: actions/checkout@v4 | |
- # https://github.com/marketplace/actions/docker-metadata-action | |
name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
name/app | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'stable') }} | |
type=ref,event=branch,enable=${{ github.ref == format('refs/heads/{0}', 'test') }} | |
type=ref,event=tag | |
type=sha | |
- # https://github.com/marketplace/actions/docker-setup-qemu | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- # https://github.com/marketplace/actions/docker-setup-buildx | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- # https://github.com/marketplace/actions/docker-login | |
name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- # https://github.com/marketplace/actions/build-and-push-docker-images | |
name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./dockerfiles | |
file: gispy.dockerfile | |
# push: true | |
push: ${{ github.event_name == 'push' }} | |
# tags: user/app:latest | |
tags: ${{ steps.meta.outputs.tags }} |