Skip to content

Create Docker image and publish to GH Packages #51

Create Docker image and publish to GH Packages

Create Docker image and publish to GH Packages #51

name: Create Docker image and publish to GH Packages
on:
push:
tags:
- "*" # only when a new tag is pushed ("v*"?)
env:
DOCKER_REGISTRY: ghcr.io # where to register the image
OS_NAME: debian
COMPILER: clang
R_VERSION: R-devel
REPO_PATH: github.com:furrer-lab/devel-abn.git
jobs:
build-and-push:
runs-on: ubuntu-22.04
permissions: # for `GITHUB_TOKEN`
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract tags and labels
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
# TODO: set a proper name of the image (same as in context below)
images: ${{ env.DOCKER_REGISTRY}}/${{ format('{0}/{1}/{2}/{3}', github.repository, env.OS_NAME, env.COMPILER, env.R_VERSION ) }}
tags: | # set Docker tags to git tags
type=semver,pattern={{version}}
- name: Write the ssh key file
run: |
echo "${{ secrets.DEVEL_ABN_DEPLOY }}" >> ssh_key
shell: bash
- name: Build and push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: ${{ format('./containers/{0}/{1}/{2}/', env.OS_NAME, env.COMPILER, env.R_VERSION ) }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
FLAVOUR=${{ env.R_VERSION }}
REPO_PATH=${{ env.REPO_PATH }}
secret-files: |
key=./ssh_key