Skip to content

Guard against concurrent launcher sessions #5

Guard against concurrent launcher sessions

Guard against concurrent launcher sessions #5

name: Build and Push Docker Images
on:
push:
branches:
- main
- master
paths-ignore:
- '**.md'
- 'docs/**'
- '.gitignore'
pull_request:
branches:
- main
- master
release:
types: [published]
workflow_dispatch:
env:
DOCKER_USERNAME: saldenisov
IMAGE_NAME: skana
jobs:
r-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up R
uses: r-lib/actions/setup-r@v2
with:
r-version: '4.4.1'
- name: Install test dependencies
shell: Rscript {0}
run: |
options(repos = c(CRAN = "https://cloud.r-project.org"))
install.packages(c(
"shiny", "shinythemes", "shinycssloaders", "DT", "outliers",
"nnls", "Iso", "httpuv", "Rsolnp", "fields", "NMFN",
"rgenoud", "mvtnorm", "deSolve", "msm", "xtable", "magrittr",
"RColorBrewer", "viridisLite", "changepoint", "testthat",
"withr", "purrr", "callr", "processx"
))
if (!requireNamespace("shinyBS", quietly = TRUE)) {
try(install.packages("shinyBS"), silent = TRUE)
if (!requireNamespace("shinyBS", quietly = TRUE)) {
install.packages("remotes")
remotes::install_github("ebailey78/shinyBS")
}
}
- name: Run testthat suite
run: Rscript tests/testthat.R
build-and-push:
needs: r-tests
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push amd64 image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest-amd64
cache-from: type=registry,ref=${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:buildcache-amd64
cache-to: type=registry,ref=${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:buildcache-amd64,mode=max
- name: Build and push arm64 image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.arm64
platforms: linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest-arm64
cache-from: type=registry,ref=${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:buildcache-arm64
cache-to: type=registry,ref=${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:buildcache-arm64,mode=max
- name: Create and push multi-platform manifest
if: github.event_name != 'pull_request'
run: |
docker buildx imagetools create -t ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest \
${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest-amd64 \
${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest-arm64
- name: Inspect multi-platform image
if: github.event_name != 'pull_request'
run: |
docker buildx imagetools inspect ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest
- name: Summary
if: github.event_name != 'pull_request'
run: |
echo "### Docker Images Published :rocket:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Repository:** \`${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
echo "- \`latest\` (multi-platform: amd64, arm64)" >> $GITHUB_STEP_SUMMARY
echo "- \`latest-amd64\` (for Windows, Linux, Intel Mac)" >> $GITHUB_STEP_SUMMARY
echo "- \`latest-arm64\` (for Mac Apple Silicon)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Usage:**" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
echo "# Multi-platform (automatically selects correct architecture)" >> $GITHUB_STEP_SUMMARY
echo "docker run -d -p 3840:3840 --name skana ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "# Or specify architecture explicitly" >> $GITHUB_STEP_SUMMARY
echo "docker run -d -p 3840:3840 --name skana ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest-amd64" >> $GITHUB_STEP_SUMMARY
echo "docker run -d -p 3840:3840 --name skana ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest-arm64" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY