|
7 | 7 | branches: |
8 | 8 | - main |
9 | 9 | release: |
10 | | - types: [published] |
11 | | -env: |
12 | | - BUILDX_CACHE: /tmp/.buildx-cache |
13 | | - CACHE_KEY: docker-erddap-buildx- |
| 10 | + types: |
| 11 | + - published |
14 | 12 |
|
15 | 13 | jobs: |
16 | 14 | build: |
17 | 15 | name: Build and test Docker Image |
18 | 16 | runs-on: ubuntu-22.04 |
19 | 17 | timeout-minutes: 10 |
20 | 18 |
|
21 | | - strategy: |
22 | | - matrix: |
23 | | - include: |
24 | | - #amd64 |
25 | | - - platform: "linux/amd64" |
26 | | - tag: "${{ vars.DOCKER_TAG }}" |
27 | | - base: "${{ vars.TOMCAT_AMD64_IMAGE }}" |
28 | | - #arm64/v8 |
29 | | - - platform: "linux/arm64/v8" |
30 | | - tag: "${{ vars.DOCKER_TAG }}" |
31 | | - base: "${{ vars.TOMCAT_ARM64_IMAGE }}" |
32 | | - |
33 | 19 | steps: |
34 | | - - name: Checkout |
35 | | - uses: actions/checkout@v4 |
36 | | - |
37 | 20 | - name: Docker meta |
38 | 21 | id: meta |
39 | 22 | uses: docker/metadata-action@v5 |
40 | 23 | with: |
41 | 24 | images: | |
42 | 25 | axiom/docker-erddap |
| 26 | + flavor: | |
| 27 | + suffix=-jdk21-openjdk |
43 | 28 | tags: | |
44 | | - type=raw,value=${{ matrix.tag }},prefix=latest- |
45 | | - type=raw,value=${{ github.event.release.tag_name }},suffix=-${{ matrix.tag }},enable=${{ github.event_name == 'release' && github.event.action == 'published' }} |
| 29 | + type=raw,value=latest,enable={{is_default_branch}} |
| 30 | + type=ref,event=tag |
46 | 31 |
|
47 | 32 | - name: Set up Docker Buildx |
48 | 33 | uses: docker/setup-buildx-action@v3 |
49 | 34 |
|
50 | | - - name: Cache Docker layers |
51 | | - uses: actions/cache@v4 |
52 | | - with: |
53 | | - path: ${ BUILDX_CACHE } |
54 | | - key: ${ CACHE_KEY }${{ github.sha }} |
55 | | - restore-keys: | |
56 | | - ${ CACHE_KEY } |
57 | | -
|
58 | 35 | - name: Build image |
59 | 36 | uses: docker/build-push-action@v6 |
60 | 37 | with: |
61 | 38 | push: false |
62 | | - platforms: ${{ matrix.platform }} |
| 39 | + platforms: linux/amd64,linux/arm64/v8 |
63 | 40 | tags: ${{ steps.meta.outputs.tags }} |
64 | 41 | labels: ${{ steps.meta.outputs.labels }} |
65 | | - build-args: | |
66 | | - BASE_IMAGE=${{ matrix.base }} |
67 | | - cache-from: type=local,src=${ BUILDX_CACHE } |
68 | | - cache-to: type=local,dest=${ BUILDX_CACHE } |
| 42 | + cache-from: type=gha |
| 43 | + cache-to: type=gha,mode=max |
69 | 44 | outputs: type=docker |
70 | 45 |
|
71 | 46 | - name: Run Docker Image in Background |
72 | | - if: matrix.platform == 'linux/amd64' |
73 | 47 | run: docker run -d -p 8080:8080 ${{ fromJSON(steps.meta.outputs.json).tags[0] }} |
74 | 48 |
|
75 | 49 | - name: Check that ERDDAP Docker Image will return a 200 |
76 | | - if: matrix.platform == 'linux/amd64' |
77 | 50 | uses: ifaxity/wait-on-action@v1 |
78 | 51 | timeout-minutes: 1 |
79 | 52 | with: |
80 | 53 | resource: http://localhost:8080/erddap/index.html |
81 | 54 |
|
82 | | - push: |
83 | | - name: Push latest image to Docker Hub |
84 | | - runs-on: ubuntu-22.04 |
85 | | - timeout-minutes: 10 |
86 | | - needs: build |
87 | | - if: (github.event_name == 'release' && github.event.action == 'published') || (github.ref == 'refs/heads/main') && github.repository == 'axiom-data-science/docker-erddap' |
88 | | - |
89 | | - strategy: |
90 | | - matrix: |
91 | | - include: |
92 | | - #amd64 |
93 | | - - platform: "linux/amd64" |
94 | | - tag: "${{ vars.DOCKER_TAG }}" |
95 | | - base: "${{ vars.TOMCAT_AMD64_IMAGE }}" |
96 | | - #arm64/v8 |
97 | | - - platform: "linux/arm64/v8" |
98 | | - tag: "${{ vars.DOCKER_TAG }}" |
99 | | - base: "${{ vars.TOMCAT_ARM64_IMAGE }}" |
100 | | - |
101 | | - steps: |
102 | | - - name: Checkout |
103 | | - uses: actions/checkout@v4 |
104 | | - |
105 | | - - name: Docker meta |
106 | | - id: meta |
107 | | - uses: docker/metadata-action@v5 |
108 | | - with: |
109 | | - images: | |
110 | | - axiom/docker-erddap |
111 | | - tags: | |
112 | | - type=raw,value=${{ matrix.tag }},prefix=latest- |
113 | | - type=raw,value=${{ github.event.release.tag_name }},suffix=-${{ matrix.tag }},enable=${{ github.event_name == 'release' && github.event.action == 'published' }} |
114 | | -
|
115 | | - - name: Set up Docker Buildx |
116 | | - uses: docker/setup-buildx-action@v3 |
117 | | - |
118 | | - - name: Cache Docker layers |
119 | | - uses: actions/cache@v4 |
120 | | - with: |
121 | | - path: ${ BUILDX_CACHE } |
122 | | - key: ${ CACHE_KEY }${{ github.sha }} |
123 | | - restore-keys: | |
124 | | - ${ CACHE_KEY } |
125 | | -
|
126 | | - - name: Login to Docker Hub |
127 | | - uses: docker/login-action@v3 |
128 | | - with: |
129 | | - username: ${{ secrets.DOCKER_USERNAME }} |
130 | | - password: ${{ secrets.DOCKER_PASSWORD }} |
131 | | - |
132 | | - - name: Push to Docker Hub |
133 | | - uses: docker/build-push-action@v6 |
134 | | - with: |
135 | | - push: true |
136 | | - platforms: ${{ matrix.platform }} |
137 | | - tags: ${{ steps.meta.outputs.tags }} |
138 | | - labels: ${{ steps.meta.outputs.labels }} |
139 | | - build-args: | |
140 | | - BASE_IMAGE=${{ matrix.base }} |
141 | | - cache-from: type=local,src=${ BUILDX_CACHE } |
142 | | - cache-to: type=local,dest=${ BUILDX_CACHE } |
143 | | - |
144 | | - - name: Update repo description |
145 | | - uses: peter-evans/dockerhub-description@v4 |
146 | | - with: |
147 | | - username: ${{ secrets.DOCKER_USERNAME }} |
148 | | - password: ${{ secrets.DOCKER_PASSWORD }} |
149 | | - repository: axiom/docker-erddap |
| 55 | + - name: Publish Docker images |
| 56 | + if: | |
| 57 | + ((github.event_name == 'release' && github.event.action == 'published') || github.ref == 'refs/heads/main') |
| 58 | + && github.repository == 'axiom-data-science/docker-erddap' |
| 59 | + uses: .github/actions/publish_docker_image |
0 commit comments