Skip to content

fingers crossed

fingers crossed #7

name: Docker Build (manual)
env:
DEFAULT_R_VERSION: 4.4
on:
push:
branches:
- main
- develop
tags:
- "v*.*.*"
pull_request:
merge_group:
workflow_dispatch:
inputs:
r_version:
description: 'R version to use'
required: true
type: choice
default: "$DEFAULT_R_VERSION"
options:
- 4.1
- 4.2
- 4.3
- 4.4
- devel
schedule:
# 1:30 AM UTC, different R version each day
- cron: '30 1 * * 1' # Rdevel
- cron: '30 1 * * 2' # R4.4
- cron: '30 1 * * 3' # R4.3
- cron: '30 1 * * 4' # R4.2
- cron: '30 1 * * 5' # R4.1
jobs:
# ----------------------------------------------------------------------
# Set R version.
# This is a hack: We really just want a global env var here, but it seems
# `env:` values can't be passed into a `jobs.<jobid>.with` context
# (see https://github.com/actions/runner/issues/2372).
# As an ugly workaround, we assign it to a job output instead.
# ----------------------------------------------------------------------
rversion:
runs-on: ubuntu-latest
steps:
- id: mon
if: github.event.schedule == '30 1 * * 1'
run: echo "R_VERSION=devel" >> "$GITHUB_OUTPUT"
- id: tue
if: github.event.schedule == '30 1 * * 2'
run: echo "R_VERSION=4.4" >> "$GITHUB_OUTPUT"
- id: wed
if: github.event.schedule == '30 1 * * 3'
run: echo "R_VERSION=4.3" >> "$GITHUB_OUTPUT"
- id: thu
if: github.event.schedule == '30 1 * * 4'
run: echo "R_VERSION=4.2" >> "$GITHUB_OUTPUT"
- id: fri
if: github.event.schedule == '30 1 * * 5'
run: echo "R_VERSION=4.1" >> "$GITHUB_OUTPUT"
- id: default
if: github.event_name != 'schedule'
run: echo "R_VERSION=${{ github.event.inputs.r_version || env.DEFAULT_R_VERSION }}" >> "$GITHUB_OUTPUT"
outputs:
# Note: "steps.*" seems to mean "all step ids", not "all steps"
# If seeing weird results here, check that all steps above have an id set.
R_VERSION: ${{ join(steps.*.outputs.R_VERSION, '') }}
depends:
name: depends / build
needs: [rversion]
runs-on: ubuntu-latest
permissions:
packages: write
env:
R_VERSION: ${{ needs.rversion.outputs.R_VERSION }}
DEFAULT_R_VERSION: 4.4
PUSH: ${{ github.event_name != 'pull_request' }}
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: ${{ env.PUSH == 'true' && secrets.DOCKERHUB_USERNAME != '' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
if: ${{ env.PUSH == 'true' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# ---------- helper: emit tags for a target ----------
- name: Docker meta (depends)
id: meta_depends
uses: docker/metadata-action@v5
env:
is_default_R: ${{ env.R_VERSION == env.DEFAULT_R_VERSION }}
check_var: ${{ secrets.DOCKERHUB_USERNAME }}
with:
images: |
name=ghcr.io/${{ github.repository_owner }}/depends
name=pecan/depends,enable=${{ env.check_var != null }}
tags: |
type=schedule
type=ref,event=branch,enable=${{ env.is_default_R }}
type=ref,event=branch,suffix=-R${{ env.R_VERSION }}
type=ref,event=pr
type=semver,pattern={{version}},enable=${{ env.is_default_R }}
type=semver,pattern={{major}}.{{minor}},enable=${{ env.is_default_R }}
type=semver,pattern={{major}},enable=${{ env.is_default_R }}
type=semver,pattern={{version}},suffix=-R${{ env.R_VERSION }}
- name: Build & push depends
uses: docker/build-push-action@v6
with:
context: docker/depends
file: docker/depends/Dockerfile
push: ${{ env.PUSH }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta_depends.outputs.tags }}
labels: ${{ steps.meta_depends.outputs.labels }}
build-args: |
R_VERSION=${{ env.R_VERSION }}
GITHUB_PAT=${{ secrets.GITHUB_TOKEN }}
- name: Docker meta (base)
id: meta_base
uses: docker/metadata-action@v5
env:
is_default_R: ${{ env.R_VERSION == env.DEFAULT_R_VERSION }}
check_var: ${{ secrets.DOCKERHUB_USERNAME }}
with:
images: |
name=ghcr.io/${{ github.repository_owner }}/base
name=pecan/base,enable=${{ env.check_var != null }}
tags: |
type=schedule
type=ref,event=branch,enable=${{ env.is_default_R }}
type=ref,event=branch,suffix=-R${{ env.R_VERSION }}
type=ref,event=pr
type=semver,pattern={{version}},enable=${{ env.is_default_R }}
type=semver,pattern={{major}}.{{minor}},enable=${{ env.is_default_R }}
type=semver,pattern={{major}},enable=${{ env.is_default_R }}
type=semver,pattern={{version}},suffix=-R${{ env.R_VERSION }}
- name: Build & push base
uses: docker/build-push-action@v6
with:
context: .
file: docker/base/Dockerfile
push: ${{ env.PUSH }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta_base.outputs.tags }}
labels: ${{ steps.meta_base.outputs.labels }}
build-args: |
R_VERSION=${{ env.R_VERSION }}
PARENT_IMAGE=ghcr.io/${{ github.repository_owner }}/depends
GITHUB_PAT=${{ secrets.GITHUB_TOKEN }}
- name: Docker meta (models)
id: meta_models
uses: docker/metadata-action@v5
env:
is_default_R: ${{ env.R_VERSION == env.DEFAULT_R_VERSION }}
check_var: ${{ secrets.DOCKERHUB_USERNAME }}
with:
images: |
name=ghcr.io/${{ github.repository_owner }}/models
name=pecan/models,enable=${{ env.check_var != null }}
tags: |
type=schedule
type=ref,event=branch,enable=${{ env.is_default_R }}
type=ref,event=branch,suffix=-R${{ env.R_VERSION }}
type=ref,event=pr
type=semver,pattern={{version}},enable=${{ env.is_default_R }}
type=semver,pattern={{major}}.{{minor}},enable=${{ env.is_default_R }}
type=semver,pattern={{major}},enable=${{ env.is_default_R }}
type=semver,pattern={{version}},suffix=-R${{ env.R_VERSION }}
- name: Build & push models
uses: docker/build-push-action@v6
with:
context: docker/models
file: docker/models/Dockerfile
push: ${{ env.PUSH }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta_models.outputs.tags }}
labels: ${{ steps.meta_models.outputs.labels }}
build-args: |
R_VERSION=${{ env.R_VERSION }}
PARENT_IMAGE=ghcr.io/${{ github.repository_owner }}/base
GITHUB_PAT=${{ secrets.GITHUB_TOKEN }}
# ---- model binaries ----
- name: Build model binaries (basgra, biocro, ed2_git, maespa, sipnet)
if: ${{ env.PUSH == 'true' }}
run: |
set -euo pipefail
build_model() {
local NAME=$1
local CONTEXT=$2
local FILE=$3
local VERSION=$4
local PLATFORM=$5
echo "::group::meta $NAME"
echo "images=name=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/model-${NAME}-${VERSION}" > meta.hcl
echo "::endgroup::"
docker buildx build \
--push \
--platform "$PLATFORM" \
--build-arg R_VERSION=${R_VERSION} \
--build-arg PARENT_IMAGE=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/models \
--build-arg MODEL_VERSION=${VERSION} \
-t ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/model-${NAME}-${VERSION} \
-f $FILE $CONTEXT
}
build_model basgra models/basgra models/basgra/Dockerfile BASGRA_N_v1 linux/amd64
build_model biocro models/biocro models/biocro/Dockerfile 0.95 linux/amd64
build_model ed2 models/ed models/ed/Dockerfile git linux/amd64
build_model maespa models/maespa models/maespa/Dockerfile git linux/amd64
build_model sipnet models/sipnet models/sipnet/Dockerfile git linux/amd64
# ---- baseplus (docs, executor, api) ----
- name: Build & push baseplus: docs

Check failure on line 243 in .github/workflows/docker-build-image.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/docker-build-image.yml

Invalid workflow file

You have an error in your yaml syntax on line 243
uses: docker/build-push-action@v6
with:
context: .
file: docker/docs/Dockerfile
push: ${{ env.PUSH }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ghcr.io/${{ github.repository_owner }}/docs:latest
build-args: |
R_VERSION=${{ env.R_VERSION }}
- name: Build & push baseplus: executor
uses: docker/build-push-action@v6
with:
context: docker/executor
file: docker/executor/Dockerfile
push: ${{ env.PUSH }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ghcr.io/${{ github.repository_owner }}/executor:latest
build-args: |
R_VERSION=${{ env.R_VERSION }}
- name: Build & push baseplus: api
uses: docker/build-push-action@v6
with:
context: apps/api
file: apps/api/Dockerfile
push: ${{ env.PUSH }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ghcr.io/${{ github.repository_owner }}/api:latest
build-args: |
R_VERSION=${{ env.R_VERSION }}
# ---- extras (web, shiny-dbsync, data, monitor, rstudio-nginx) ----
- name: Build & push extras: web
uses: docker/build-push-action@v6
with:
context: .
file: docker/web/Dockerfile
push: ${{ env.PUSH }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ghcr.io/${{ github.repository_owner }}/web:latest
- name: Build & push extras: shiny-dbsync
uses: docker/build-push-action@v6
with:
context: .
file: shiny/dbsync/Dockerfile
push: ${{ env.PUSH }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ghcr.io/${{ github.repository_owner }}/shiny-dbsync:latest
build-args: |
R_VERSION=${{ env.R_VERSION }}
- name: Build & push extras: data
uses: docker/build-push-action@v6
with:
context: docker/data
file: docker/data/Dockerfile
push: ${{ env.PUSH }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ghcr.io/${{ github.repository_owner }}/data:latest
- name: Build & push extras: monitor
uses: docker/build-push-action@v6
with:
context: docker/monitor
file: docker/monitor/Dockerfile
push: ${{ env.PUSH }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ghcr.io/${{ github.repository_owner }}/monitor:latest
- name: Build & push extras: rstudio-nginx
uses: docker/build-push-action@v6
with:
context: docker/rstudio-nginx
file: docker/rstudio-nginx/Dockerfile
push: ${{ env.PUSH }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ghcr.io/${{ github.repository_owner }}/rstudio-nginx:latest