-
Notifications
You must be signed in to change notification settings - Fork 1
104 lines (87 loc) · 2.87 KB
/
docker-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Docker
on:
push:
branches:
- main
- dev
- release
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