forked from Project-OSRM/osrm-backend
-
Notifications
You must be signed in to change notification settings - Fork 7
96 lines (87 loc) · 4.18 KB
/
autobuild-osrm-backend.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Build Docker - osrm-backend
on:
push:
branches:
- '**'
paths:
- 'cmake/**'
- 'docker-orchestration/osrm-backend/**'
- 'fuzz/**'
- 'include/**'
- 'integration/**'
- 'profiles/**'
- 'src/**'
- 'third_party/**'
- 'unit_tests/**'
env:
DOCKERHUB_REGISTRY: telenavmap
OSRM_BACKEND_IMAGE_NAME: osrm-backend
OSRM_BACKEND_DOCKERFILE_PATH: docker-orchestration/osrm-backend/
OSRM_BACKEND_WITHIN_MAPDATA_IMAGE_NAME: osrm-backend-within-mapdata
OSRM_BACKEND_WITHIN_MAPDATA_DOCKERFILE_PATH: docker-orchestration/osrm-backend-within-mapdata/
jobs:
build:
name: Build osrm-backend docker
runs-on: ubuntu-latest
outputs:
image-tag: ${{ steps.step-output-image-tag.outputs.output_var }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set IMAGE_TAG env # env IMAGE_TAG=BranchName-CommitID-Timestamp
run: echo IMAGE_TAG=$(echo ${GITHUB_REF} | rev | cut -d'/' -f 1 | rev )-$(echo ${GITHUB_SHA} | cut -c 1-7)-$(date -u +"%Y%m%d") >> ${GITHUB_ENV}
- id: step-output-image-tag
run: echo "::set-output name=output_var::${{ env.IMAGE_TAG }}"
- name: Comma-separated image tags
run: echo COMMA_SEPARATED_IMAGE_TAGS=${IMAGE_TAG} >> ${GITHUB_ENV}
- name: Append latest if on master branch # env '${IMAGE_TAG},latest'
if: endsWith(github.ref, 'master')
run: echo COMMA_SEPARATED_IMAGE_TAGS=${COMMA_SEPARATED_IMAGE_TAGS},latest >> ${GITHUB_ENV}
- name: Environment Printer
uses: managedkaos/[email protected]
- name: Build & Publish to DockerHub
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.OSRM_BACKEND_IMAGE_NAME }}
username: ${{ secrets.TELENAVMAP_DOCKERHUB_USERNAME }}
password: ${{ secrets.TELENAVMAP_DOCKERHUB_TOKEN }}
snapshot: false
workdir: ${{ env.OSRM_BACKEND_DOCKERFILE_PATH }}
tags: "${{ env.COMMA_SEPARATED_IMAGE_TAGS }}"
buildargs: "GIT_COMMIT=${{ github.sha }},IMAGE_TAG=${{ env.IMAGE_TAG }}"
compile-data:
name: Compile map data
runs-on: ubuntu-latest
needs: build
env:
BUILT_OSRM_BACKEND_IMAGE_TAG: ${{ needs.build.outputs.image-tag }}
COMPILED_DATA_PATH: map
SAMPLE_PROFILE: profiles/car.lua
SAMPLE_OSM_MAPDATA: https://download.geofabrik.de/north-america/us/nevada-latest.osm.pbf
steps:
- name: Set DATA_IMAGE_TAG env
run: echo DATA_IMAGE_TAG=$(echo ${BUILT_OSRM_BACKEND_IMAGE_TAG} )-$(basename ${SAMPLE_OSM_MAPDATA%.osm.pbf}) >> ${GITHUB_ENV}
- name: Comma-separated image tags
run: echo COMMA_SEPARATED_DATA_IMAGE_TAGS=${DATA_IMAGE_TAG} >> ${GITHUB_ENV}
- name: Append latest if on master branch # env '${IMAGE_TAG},latest'
if: endsWith(github.ref, 'master')
run: echo COMMA_SEPARATED_DATA_IMAGE_TAGS=${COMMA_SEPARATED_DATA_IMAGE_TAGS},latest >> ${GITHUB_ENV}
- name: Environment Printer
uses: managedkaos/[email protected]
- name: pull built image
run: docker pull "${{ env.DOCKERHUB_REGISTRY }}/${{ env.OSRM_BACKEND_IMAGE_NAME }}:${{ env.BUILT_OSRM_BACKEND_IMAGE_TAG }}"
- name: Checkout
uses: actions/checkout@v2
- name: Compile data
run: |
cd ${{ env.OSRM_BACKEND_WITHIN_MAPDATA_DOCKERFILE_PATH }} && mkdir -p ${{ env.COMPILED_DATA_PATH }} && docker run --mount "src=$(pwd)/${{ env.COMPILED_DATA_PATH }},dst=/compiled-data,type=bind" "${{ env.DOCKERHUB_REGISTRY }}/${{ env.OSRM_BACKEND_IMAGE_NAME }}:${{ env.BUILT_OSRM_BACKEND_IMAGE_TAG }}" compile_mapdata "${{ env.SAMPLE_PROFILE }}" "${{ env.SAMPLE_OSM_MAPDATA }}"
- name: Build & Publish osrm-backend-within-mapdata to DockerHub
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.OSRM_BACKEND_WITHIN_MAPDATA_IMAGE_NAME }}
username: ${{ secrets.TELENAVMAP_DOCKERHUB_USERNAME }}
password: ${{ secrets.TELENAVMAP_DOCKERHUB_TOKEN }}
snapshot: false
workdir: ${{ env.OSRM_BACKEND_WITHIN_MAPDATA_DOCKERFILE_PATH }}
tags: "${{ env.COMMA_SEPARATED_DATA_IMAGE_TAGS }}"
buildargs: "FROM_TAG=${{ env.BUILT_OSRM_BACKEND_IMAGE_TAG }}"