-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (134 loc) · 5.63 KB
/
Copy pathdocker-build-push.yml
File metadata and controls
153 lines (134 loc) · 5.63 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
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