Build and publish Docker image #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow builds a Docker image from the repo's Dockerfile and pushes it | |
# to Docker Hub if the triggering event was a tag push. When it's a scheduled | |
# run, it just builds the image as a test, but does not push it. | |
name: Build and publish Docker image | |
on: | |
push: | |
tags: | |
- v* | |
schedule: | |
- cron: 50 4 * * 1 # every monday at 04:50 UTC | |
jobs: | |
build_publish_docker: | |
if: ${{ github.repository == 'gboeing/osmnx' }} | |
name: Build/publish image to Docker Hub | |
runs-on: ubuntu-latest | |
timeout-minutes: 90 | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: gboeing | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Extract tags for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
flavor: latest=auto | |
images: gboeing/osmnx | |
- name: Set up Docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./environments/docker/Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} | |
tags: ${{ steps.meta.outputs.tags }} |