-
Notifications
You must be signed in to change notification settings - Fork 26
150 lines (131 loc) · 4.63 KB
/
push.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
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
name: Push
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
release:
types: [published]
env:
BUILDX_CACHE: /tmp/.buildx-cache
CACHE_KEY: docker-erddap-buildx-
jobs:
build:
name: Build and test Docker Image
runs-on: ubuntu-20.04
timeout-minutes: 10
strategy:
#NOTE: make sure to replicate this matrix config in the push job below
matrix:
include:
#amd64
- platform: "linux/amd64"
tag: "jdk17-openjdk"
base: "tomcat:10.1.16-jdk17-temurin-jammy@sha256:5d06ae2052b1a4c636454e65360a712fd262eebf574f8a97f37c2580edce7d46"
#arm64/v8
- platform: "linux/arm64/v8"
tag: "jdk17-openjdk"
base: "tomcat:10.1.16-jdk17-temurin-jammy@sha256:7d930ac5ba9091aa12c1a42e3cc7c59c12c8d032e076c3713c10bb9b35227b5d"
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
axiom/docker-erddap
tags: |
type=raw,value=${{ matrix.tag }},prefix=latest-
type=raw,value=${{ github.event.release.tag_name }},suffix=-${{ matrix.tag }},enable=${{ github.event_name == 'release' && github.event.action == 'published' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: ${ BUILDX_CACHE }
key: ${ CACHE_KEY }${{ github.sha }}
restore-keys: |
${ CACHE_KEY }
- name: Build image
uses: docker/build-push-action@v2
with:
push: false
platforms: ${{ matrix.platform }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BASE_IMAGE=${{ matrix.base }}
cache-from: type=local,src=${ BUILDX_CACHE }
cache-to: type=local,dest=${ BUILDX_CACHE }
outputs: type=docker
- name: Run Docker Image in Background
if: matrix.platform == 'linux/amd64'
run: docker run -d -p 8080:8080 ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
- name: Check that ERDDAP Docker Image will return a 200
if: matrix.platform == 'linux/amd64'
uses: ifaxity/wait-on-action@v1
timeout-minutes: 1
with:
resource: http://localhost:8080/erddap/index.html
push:
name: Push latest image to Docker Hub
runs-on: ubuntu-20.04
timeout-minutes: 10
needs: build
if: (github.event_name == 'release' && github.event.action == 'published') || (github.ref == 'refs/heads/main') && github.repository == 'axiom-data-science/docker-erddap'
strategy:
matrix:
include:
#amd64
- platform: "linux/amd64"
tag: "jdk17-openjdk"
base: "tomcat:10.1.16-jdk17-temurin-jammy@sha256:5d06ae2052b1a4c636454e65360a712fd262eebf574f8a97f37c2580edce7d46"
#arm64/v8
- platform: "linux/arm64/v8"
tag: "jdk17-openjdk"
base: "tomcat:10.1.16-jdk17-temurin-jammy@sha256:7d930ac5ba9091aa12c1a42e3cc7c59c12c8d032e076c3713c10bb9b35227b5d"
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
axiom/docker-erddap
tags: |
type=raw,value=${{ matrix.tag }},prefix=latest-
type=raw,value=${{ github.event.release.tag_name }},suffix=-${{ matrix.tag }},enable=${{ github.event_name == 'release' && github.event.action == 'published' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: ${ BUILDX_CACHE }
key: ${ CACHE_KEY }${{ github.sha }}
restore-keys: |
${ CACHE_KEY }
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push to Docker Hub
uses: docker/build-push-action@v2
with:
push: true
platforms: ${{ matrix.platform }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BASE_IMAGE=${{ matrix.base }}
cache-from: type=local,src=${ BUILDX_CACHE }
cache-to: type=local,dest=${ BUILDX_CACHE }
- name: Update repo description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: axiom/docker-erddap