|
| 1 | +name: Build Navitia Dockers |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - dev |
| 7 | + tags: |
| 8 | + - '*' |
| 9 | +env: |
| 10 | + debian_version: debian8 |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + container: |
| 18 | + image: navitia/${{env.debian_version}}_dev |
| 19 | + volumes: |
| 20 | + # Mount so we can delete files from docker and free up space (>20GB) |
| 21 | + - /usr/share/dotnet:/usr/share/dotnet |
| 22 | + - /usr/local/lib/android:/usr/local/lib/android |
| 23 | + |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Free up space |
| 27 | + run: | |
| 28 | + rm -rf /usr/share/dotnet/* |
| 29 | + rm -rf /usr/local/lib/android/* |
| 30 | + echo "Free space:" |
| 31 | + df -h |
| 32 | +
|
| 33 | + - name: Install dependencies |
| 34 | + run: | |
| 35 | + apt update && apt install -y --force-yes zip httpie dh-python |
| 36 | +
|
| 37 | + - name: Checkout core_team_ci_tools |
| 38 | + uses: actions/checkout@v3 |
| 39 | + with: |
| 40 | + path: core_team_ci_tools |
| 41 | + repository : 'hove-io/core_team_ci_tools' |
| 42 | + |
| 43 | + - name: Setup core_team_ci_tools python environment |
| 44 | + run: | |
| 45 | + pip install -r core_team_ci_tools/github_artifacts/requirements.txt --user |
| 46 | +
|
| 47 | + - name: Download mimirsbrunn package |
| 48 | + run: | |
| 49 | + mimirsbrunn_package="debian-package-release.zip" |
| 50 | + python core_team_ci_tools/github_artifacts/github_artifacts.py \ |
| 51 | + -o hove-io \ |
| 52 | + -r mimirsbrunn \ |
| 53 | + -t ${{secrets.access_token_github}} \ |
| 54 | + -w release.yml \ |
| 55 | + -a $mimirsbrunn_package \ |
| 56 | + --output-dir . |
| 57 | + unzip -qo $mimirsbrunn_package |
| 58 | + rm -f $mimirsbrunn_package |
| 59 | +
|
| 60 | + - name: Download cosmogony2cities package |
| 61 | + run: | |
| 62 | + cosmogony2cities_package="package-${{env.debian_version}}.zip" |
| 63 | + python core_team_ci_tools/github_artifacts/github_artifacts.py \ |
| 64 | + -o hove-io \ |
| 65 | + -r cosmogony2cities \ |
| 66 | + -t ${{secrets.access_token_github}} \ |
| 67 | + -w build_package.yml \ |
| 68 | + -a $cosmogony2cities_package \ |
| 69 | + --output-dir . |
| 70 | + unzip -qo $cosmogony2cities_package |
| 71 | + rm -f $cosmogony2cities_package |
| 72 | +
|
| 73 | + - name: Download libkeepalive |
| 74 | + run: | |
| 75 | + wget http://prdownloads.sourceforge.net/libkeepalive/libkeepalive-0.3.tar.gz |
| 76 | +
|
| 77 | + - name: Restore ccache |
| 78 | + uses: hendrikmuhs/[email protected] |
| 79 | + with: |
| 80 | + key: ${{env.debian_version}-package |
| 81 | + max-size: 2000M |
| 82 | + save: ${{ github.event_name == 'push' }} |
| 83 | + |
| 84 | + - name: Checkout navitia |
| 85 | + uses: actions/checkout@v3 |
| 86 | + with: |
| 87 | + submodules : recursive |
| 88 | + path: navitia |
| 89 | + fetch-depth: 0 |
| 90 | + |
| 91 | + - name: Build navitia packages |
| 92 | + working-directory: navitia |
| 93 | + # Will build navitia-*.deb packages in folder ../ |
| 94 | + run: | |
| 95 | + DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -b |
| 96 | +
|
| 97 | +
|
| 98 | + # see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable |
| 99 | + - name: Choose dev navitia tag |
| 100 | + if: github.event_name == 'push' && github.ref == 'refs/heads/dev' |
| 101 | + run: | |
| 102 | + echo "building version dev" |
| 103 | + echo "navitia_tag=dev" >> $GITHUB_ENV |
| 104 | + echo "aws_branch=dev" >> $GITHUB_ENV |
| 105 | +
|
| 106 | + - name: Choose release navitia tag |
| 107 | + if: startsWith(github.ref, 'refs/tags/') |
| 108 | + run: | |
| 109 | + cd navitia |
| 110 | + version=$(git describe) |
| 111 | + echo "building version $version" |
| 112 | + echo "navitia_tag=$version" >> $GITHUB_ENV |
| 113 | + echo "aws_branch=release" >> $GITHUB_ENV |
| 114 | +
|
| 115 | + - name: Create dockers images and push them |
| 116 | + run: | |
| 117 | + docker build -f navitia/docker/${{env.debian_version}}/Dockerfile-master -t navitia/master . |
| 118 | +
|
| 119 | + components='jormungandr kraken tyr-beat tyr-worker tyr-web instances-configurator mock-kraken eitri' |
| 120 | + for component in $components; do |
| 121 | + echo "********* Building $component ***************" |
| 122 | + docker build -t navitia/$component:${{env.navitia_tag}} -f navitia/docker/${{env.debian_version}}/Dockerfile-${component} . |
| 123 | +
|
| 124 | + # add latest tag if navitia_tag != dev |
| 125 | + if [[ "${{env.navitia_tag}}" != "dev" ]]; then |
| 126 | + docker tag navitia/$component:${{env.navitia_tag}} navitia/$component:latest |
| 127 | + fi |
| 128 | + done |
| 129 | +
|
| 130 | + docker login -u ${{secrets.docker_user}} -p ${{secrets.docker_password}} |
| 131 | +
|
| 132 | + for component in $components; do |
| 133 | + echo "********* Pushing $component ***************" |
| 134 | + docker push --all-tags navitia/$component:${{env.navitia_tag}} |
| 135 | + done |
| 136 | +
|
| 137 | + - name: Generate token for aws images |
| 138 | + id: app-token |
| 139 | + |
| 140 | + with: |
| 141 | + app_id: ${{ secrets.GA_OS_WORKFLOW_TRIGGER_APP_ID }} |
| 142 | + private_key: ${{ secrets.GA_OS_WORKFLOW_TRIGGER_APP_PEM }} |
| 143 | + |
| 144 | + - name: Aws Dispatch Backend |
| 145 | + uses: peter-evans/repository-dispatch@v2 |
| 146 | + with: |
| 147 | + token: ${{ steps.app-token.outputs.token }} |
| 148 | + repository: hove-io/core-backend-aws-assets |
| 149 | + event-type: build-trigger |
| 150 | + client-payload: '{"branch": "${{ env.aws_branch }}", "tag": "${{ env.navitia_tag }}"}' |
| 151 | + |
| 152 | + - name: Aws Dispatch Frontend |
| 153 | + uses: peter-evans/repository-dispatch@v2 |
| 154 | + with: |
| 155 | + token: ${{ steps.app-token.outputs.token }} |
| 156 | + repository: hove-io/core-front-aws-assets |
| 157 | + event-type: build-trigger |
| 158 | + client-payload: '{"branch": "${{ env.aws_branch }}", "tag": "${{ env.navitia_tag }}"}' |
| 159 | + |
| 160 | + - name: Run artemis on push to dev |
| 161 | + if: github.event_name == 'push' && github.ref == 'refs/heads/dev' |
| 162 | + uses: peter-evans/repository-dispatch@v2 |
| 163 | + with: |
| 164 | + token: ${{ secrets.access_token_github }} |
| 165 | + repository: hove-io/artemis |
| 166 | + event-type: run_artemis_ng |
| 167 | + |
| 168 | + - name: failure notification |
| 169 | + if: failure() |
| 170 | + run: | |
| 171 | + echo '{"text":":warning: Github Actions: build_dockers for ${{env.navitia_tag}} failed !"}' | http --json POST ${{secrets.SLACK_NAVITIA_CORE_TEAM_URL}} |
| 172 | +
|
| 173 | + - name: success notification on navitia core team |
| 174 | + if: success() |
| 175 | + run: | |
| 176 | + echo '{"text":":octopus: Github Actions: build_dockers succeeded. New navitia ${{env.navitia_tag}} image available.' | http --json POST ${{secrets.SLACK_NAVITIA_CORE_TEAM_URL}} |
0 commit comments