-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(docker-nightly): move to separate build/publish from test (#1689)
- Loading branch information
Showing
3 changed files
with
90 additions
and
40 deletions.
There are no files selected for viewing
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
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 ] | ||
|
@@ -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' | ||
|
||
|
||
|
@@ -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: | | ||
|
@@ -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 | ||
|
@@ -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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
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' | ||
ignore-24h-commit-check: | ||
description: 'Build image regardless of last commit date.' | ||
required: true | ||
type: boolean | ||
default: false | ||
user: | ||
description: '' | ||
required: false | ||
default: 'schedule' | ||
|
||
jobs: | ||
check-commits: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
new_commits: ${{ steps.check.outputs.NEW_COMMITS }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
with: | ||
repository: ${{ inputs.repository || 'GIScience/openrouteservice' }} | ||
ref: ${{ inputs.branch || 'main' }} | ||
|
||
- name: Check for new commits since 24 h ago | ||
id: check | ||
run: | | ||
export LOG_LINES=$(git log --oneline --since '24 hours ago') | ||
export NUM_LINES=$(echo "$LOG_LINES" | grep -c .) | ||
if [ "$NUM_LINES" -eq "0" ]; then | ||
export NEW_COMMITS="false" | ||
else | ||
export NEW_COMMITS="true" | ||
fi | ||
echo "NEW_COMMITS=$NEW_COMMITS" >> "$GITHUB_OUTPUT" | ||
build: | ||
needs: check-commits | ||
runs-on: ubuntu-latest | ||
if: inputs.ignore-24h-commit-check || needs.check-commits.outputs.new_commits == 'true' | ||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
with: | ||
repository: ${{ inputs.repository || 'GIScience/openrouteservice' }} | ||
ref: ${{ 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:${{ inputs.tag || 'nightly' }} |
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