Skip to content

Commit

Permalink
ci(docker-nightly): move to separate build/publish from test
Browse files Browse the repository at this point in the history
previously the nightly build was not built nightly but on many
changes in PRs as well.
This is now moved to a separate workflow that runs nightly,
with workflow_dispatch option to build images for different
branches & repos on demand.
  • Loading branch information
TheGreatRefrigerator committed Feb 14, 2024
1 parent f2627d4 commit 008cbbe
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and publish the nightly Docker image
name: Build and test the Docker image
on:
pull_request:
types: [ opened, synchronize, ready_for_review ]
Expand All @@ -8,7 +8,6 @@ on:

env:
TEST_IMAGE_NAME: 'local/openrouteservice:test'
PRODUCTION_IMAGE_NAME: 'openrouteservice/openrouteservice:nightly'
BUILD_PLATFORMS: 'linux/amd64,linux/arm64/v8'


Expand All @@ -19,7 +18,6 @@ jobs:
runs-on: ubuntu-latest
outputs:
test_image_name: ${{ env.TEST_IMAGE_NAME }}
production_image_name: ${{ env.PRODUCTION_IMAGE_NAME }}
build_platforms: ${{ env.BUILD_PLATFORMS }}
steps:
- run: |
Expand Down Expand Up @@ -47,7 +45,7 @@ jobs:
context: .
push: false
load: false
tags: ${{ needs.prepare_environment.outputs.test_image_name }}, ${{ needs.prepare_environment.outputs.production_image_name }}
tags: ${{ needs.prepare_environment.outputs.test_image_name }}
platforms: "${{ needs.prepare_environment.outputs.build_platforms }}"
cache-from: type=gha
cache-to: type=gha,mode=max
Expand Down Expand Up @@ -127,39 +125,3 @@ jobs:
./.github/utils/cors_check.sh 127.0.0.1 8080 /ors/v2/isochrones/geojson "https://example.org" 200 50
# It should fail with http code 403 for https://example.com since the Origin is not covered.
./.github/utils/cors_check.sh 127.0.0.1 8080 /ors/v2/isochrones/geojson "https://example.com" 403 10
publish_docker:
name: Publish the docker image to docker hub
runs-on: ubuntu-latest
needs:
- prepare_environment
- build_docker_images
- run_docker_image_tests
steps:
- run: |
echo "Publish image ${{ needs.prepare_environment.outputs.production_image_name }}"
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Login to DockerHub
if: ${{ success() && github.ref == 'refs/heads/main' }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Publish nightly
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ needs.prepare_environment.outputs.production_image_name }}
platforms: "${{ needs.prepare_environment.outputs.build_platforms }}"
cache-from: type=gha
58 changes: 58 additions & 0 deletions .github/workflows/docker-nightly-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Docker Nightly Image CI
run-name: Build ${{ inputs.branch }} - ${{ inputs.user }}

on:
schedule:
- cron: '15 1 * * *'
workflow_dispatch:
inputs:
repository:
description: 'GitHub repository to create image off.'
required: true
default: 'GIScience/openrouteservice'
branch:
description: 'GitHub branch to create image off.'
required: true
default: 'main'
tag:
description: 'Name of the docker tag to create.'
required: true
default: 'nightly'
user:
description: ''
required: false
default: 'schedule'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/[email protected]
with:
repository: ${{ github.event.inputs.repository || 'GIScience/openrouteservice' }}
ref: ${{ github.event.inputs.branch || 'main' }}

- name: Set up QEMU
uses: docker/[email protected]

- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
uses: docker/[email protected]
with:
context: .
platforms: linux/amd64,linux/arm64/v8
provenance: false
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ secrets.DOCKER_USERNAME }}/openrouteservice:${{ github.event.inputs.tag || 'nightly' }}

0 comments on commit 008cbbe

Please sign in to comment.