|
16 | 16 | - '.github/codecov.yml' |
17 | 17 | - 'dockerfiles/**' |
18 | 18 | pull_request: |
| 19 | + workflow_dispatch: |
| 20 | + |
19 | 21 | env: |
20 | 22 | LATEST_PY_VERSION: '3.12' |
21 | 23 |
|
@@ -120,81 +122,76 @@ jobs: |
120 | 122 | - name: Set up Docker Buildx |
121 | 123 | uses: docker/setup-buildx-action@v3 |
122 | 124 |
|
123 | | - - name: Login to DockerHub |
| 125 | + - name: Login to Docker Hub |
| 126 | + if: github.repository == 'developmentseed/titiler' |
124 | 127 | uses: docker/login-action@v3 |
125 | 128 | with: |
126 | 129 | username: ${{ secrets.DOCKERHUB_USERNAME }} |
127 | 130 | password: ${{ secrets.DOCKERHUB_TOKEN }} |
128 | 131 |
|
129 | | - - name: Login to Github |
| 132 | + - name: Log in to the GitHub Container registry |
130 | 133 | uses: docker/login-action@v3 |
131 | 134 | with: |
132 | 135 | registry: ghcr.io |
133 | 136 | username: ${{ github.actor }} |
134 | 137 | password: ${{ secrets.GITHUB_TOKEN }} |
135 | 138 |
|
136 | | - - name: Set tag version |
137 | | - id: tag |
138 | | - # https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions |
139 | | - run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} |
140 | | - # Uvicorn |
141 | | - # Push `latest` when commiting to main |
142 | | - - name: Build and push uvicorn |
143 | | - if: github.ref == 'refs/heads/main' |
144 | | - uses: docker/build-push-action@v5 |
| 139 | + - name: Docker meta (unicorn) |
| 140 | + id: meta-uvicorn |
| 141 | + uses: docker/metadata-action@v5 |
145 | 142 | with: |
146 | | - # See https://github.com/developmentseed/titiler/discussions/387 |
147 | | - platforms: linux/amd64 |
148 | | - context: . |
149 | | - file: dockerfiles/Dockerfile.uvicorn |
150 | | - push: true |
| 143 | + images: | |
| 144 | + ghcr.io/${{ github.repository }}-uvicorn |
| 145 | + flavor: | |
| 146 | + latest=false |
151 | 147 | tags: | |
152 | | - ghcr.io/${{ github.repository }}-uvicorn:latest |
| 148 | + type=semver,pattern={{version}} |
| 149 | + type=raw,value=latest,enable={{is_default_branch}} |
153 | 150 |
|
154 | | - # Push `{VERSION}` when pushing a new tag |
155 | | - - name: Build and push uvicorn |
156 | | - if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' |
157 | | - uses: docker/build-push-action@v5 |
| 151 | + - name: Docker meta (gunicorn) |
| 152 | + id: meta-gunicorn |
| 153 | + uses: docker/metadata-action@v5 |
158 | 154 | with: |
159 | | - # See https://github.com/developmentseed/titiler/discussions/387 |
160 | | - platforms: linux/amd64 |
161 | | - context: . |
162 | | - file: dockerfiles/Dockerfile.uvicorn |
163 | | - push: true |
| 155 | + images: | |
| 156 | + ghcr.io/${{ github.repository }} |
| 157 | + flavor: | |
| 158 | + latest=false |
164 | 159 | tags: | |
165 | | - ghcr.io/${{ github.repository }}-uvicorn:${{ steps.tag.outputs.tag }} |
| 160 | + type=semver,pattern={{version}} |
| 161 | + type=raw,value=latest,enable={{is_default_branch}} |
166 | 162 |
|
167 | | - # Gunicorn |
168 | | - # Push `latest` when commiting to main |
169 | | - - name: Build and push |
170 | | - if: github.ref == 'refs/heads/main' |
| 163 | + # Uvicorn |
| 164 | + - name: Build and push uvicorn |
171 | 165 | uses: docker/build-push-action@v5 |
172 | 166 | with: |
173 | | - # See https://github.com/developmentseed/titiler/discussions/387 |
174 | | - platforms: linux/amd64 |
| 167 | + # TODO: add `linux/arm64 once https://github.com/rasterio/rasterio-wheels/issues/69 is resolved |
| 168 | + platforms: linux/amd64 # ,linux/arm64 |
175 | 169 | context: . |
176 | | - file: dockerfiles/Dockerfile.gunicorn |
177 | | - push: true |
178 | | - tags: | |
179 | | - ghcr.io/${{ github.repository }}:latest |
| 170 | + file: dockerfiles/Dockerfile.uvicorn |
| 171 | + push: ${{ github.event_name != 'pull_request' }} |
| 172 | + tags: ${{ steps.meta-uvicorn.outputs.tags }} |
| 173 | + labels: ${{ steps.meta-uvicorn.outputs.labels }} |
| 174 | + cache-from: type=gha |
| 175 | + cache-to: type=gha,mode=max |
180 | 176 |
|
181 | | - # Push `{VERSION}` when pushing a new tag |
| 177 | + # Gunicorn |
182 | 178 | - name: Build and push |
183 | | - if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' |
184 | 179 | uses: docker/build-push-action@v5 |
185 | 180 | with: |
186 | | - # See https://github.com/developmentseed/titiler/discussions/387 |
187 | | - platforms: linux/amd64 |
| 181 | + # TODO: add `linux/arm64 once https://github.com/rasterio/rasterio-wheels/issues/69 is resolved |
| 182 | + platforms: linux/amd64 # ,linux/arm64 |
188 | 183 | context: . |
189 | 184 | file: dockerfiles/Dockerfile.gunicorn |
190 | | - push: true |
191 | | - tags: | |
192 | | - ghcr.io/${{ github.repository }}:${{ steps.tag.outputs.tag }} |
| 185 | + push: ${{ github.event_name != 'pull_request' }} |
| 186 | + tags: ${{ steps.meta-gunicorn.outputs.tags }} |
| 187 | + labels: ${{ steps.meta-gunicorn.outputs.labels }} |
| 188 | + cache-from: type=gha |
| 189 | + cache-to: type=gha,mode=max |
193 | 190 |
|
194 | 191 | deploy: |
195 | 192 | needs: [tests, publish] |
196 | 193 | runs-on: ubuntu-latest |
197 | | - if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' |
| 194 | + if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' && github.repository == 'developmentseed/titiler' |
198 | 195 |
|
199 | 196 | defaults: |
200 | 197 | run: |
|
0 commit comments