Update README.md #141
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
name: Docker | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
tags: [ 'v*.*.*' ] | |
pull_request: | |
branches: | |
- main | |
- dev | |
env: | |
REGISTRY: docker.io | |
IMAGE_NAME: thomasenzlein/m2ara | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Set up R environment | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: '4.3.2' | |
# Install system dependencies for R packages | |
- name: Install system dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get -y install libcurl4-openssl-dev libssl-dev libxml2-dev build-essential libxml2-dev libgit2-dev libudunits2-dev librsvg2-dev tk libharfbuzz-dev libfribidi-dev | |
# Install R package dependencies from req.txt | |
- name: Install R packages from req.txt | |
run: | | |
R -e "install.packages('pak')" | |
R -e "packages <- readLines('req.txt'); pak::pkg_install(packages)" | |
# Install R package dependencies from req.txt | |
- name: Install MALDIcellassay | |
run: | | |
R -e "pak::pkg_install('CeMOS-Mannheim/MALDIcellassay')" | |
# Install testthat if it's not listed in req.txt | |
- name: Install testthat | |
run: R -e "if (!require('testthat')) pak::pkg_install('testthat')" | |
# Run tests | |
- name: Run tests | |
run: R -e "source('tests/testthat.R')" | |
# This step will be skipped if the tests fail | |
# Set up Docker Buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3.3.0 | |
- name: Log into registry ${{ env.REGISTRY }} | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3.1.0 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ secrets.dockeriouser }} | |
password: ${{ secrets.dockeriopwd }} | |
- name: Create cache directory | |
run: mkdir -p /tmp/.buildx-cache | |
- name: Cache Docker layers | |
id: cache-docker-layers | |
uses: actions/cache@v4.0.2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5.5.1 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push Docker image | |
id: build-and-push | |
uses: docker/build-push-action@v5.3.0 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |