-
Notifications
You must be signed in to change notification settings - Fork 10
116 lines (94 loc) · 3.24 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
105
106
107
108
109
110
111
112
113
114
115
116
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ published ]
name: Docker
jobs:
build-docker-image:
strategy:
fail-fast: false
matrix:
include:
- dockerfile: docker/Dockerfile
image: weecology/portalcasting
image_name: base
tag_prefix: ''
- dockerfile: docker/Dockerfile
image: weecology/portalcasting
image_name: sandbox
tag_prefix: sandbox_
- dockerfile: docker/Dockerfile
image: weecology/portalcasting
image_name: production
tag_prefix: production_
runs-on: ubuntu-latest
name: ${{ matrix.image_name }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
if: ${{ github.event_name == 'release' }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ matrix.image }}
tags: |
type=raw,value=${{ matrix.tag_prefix }}latest
type=semver,pattern={{raw}},prefix=${{ matrix.tag_prefix }}
- name: Build ${{ matrix.image_name }} image
uses: docker/build-push-action@v4
with:
context: .
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ${{ matrix.dockerfile }}
build-args: |
"event_sha=${{ github.sha }}"
"image_name=${{ matrix.image_name }}"
- name: Test ${{ matrix.image_name }} image
run: |
docker run weecology/portalcasting:${{ matrix.tag_prefix }}latest r -e "library(portalcasting)"
- name: Push ${{ matrix.image_name }} image
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name == 'release' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ${{ matrix.dockerfile }}
build-args: |
"event_sha=${{ github.sha }}"
"image_name=${{ matrix.image_name }}"
- name: Update dockerhub descriptions upon release
if: ${{ github.event_name == 'release' }}
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: weecology/portalcasting
readme-filepath: ./docker/README.md
short-description: ${{ github.event.repository.description }}