Release #85
This file contains hidden or 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
| name: "Release" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: 'Environment' | |
| required: true | |
| default: 'dev' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| name: Build, Push, Deploy (dev) | |
| environment: "dev" | |
| timeout-minutes: 45 | |
| steps: | |
| - uses: actions/checkout@v2 | |
| with: | |
| submodules: recursive | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ vars.WS_DOCKER_REGISTRY }} | |
| username: ${{ vars.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set commit SHA as code version | |
| run: echo "CODE_VERSION=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV | |
| - name: "Build Changelog" | |
| id: build_changelog | |
| uses: mikepenz/release-changelog-builder-action@v5 | |
| - name: Build and push | |
| run: docker compose -f docker-compose.build.yml --env-file tdei_uw.env build --build-arg CODE_VERSION=${CODE_VERSION} | |
| env: | |
| ENV: ${{ vars.ENV }} | |
| WS_DOCKER_REGISTRY: ${{ vars.WS_DOCKER_REGISTRY }} | |
| # passwords | |
| WS_API_DB_PASS: ${{ secrets.WS_API_DB_PASS }} | |
| WS_MAPBOX_ACCESS_TOKEN: ${{ secrets.WS_MAPBOX_ACCESS_TOKEN }} | |
| WS_OSM_DB_PASS: ${{ secrets.WS_OSM_DB_PASS }} | |
| WS_OSM_SECRET_KEY_BASE: ${{ secrets.WS_OSM_SECRET_KEY_BASE }} | |
| WS_SMTP_PASS: ${{ secrets.WS_SMTP_PASS }} | |
| WS_TASKS_DB_PASS: ${{ secrets.WS_TASKS_DB_PASS }} | |
| WS_TASKS_SECRET_KEY: ${{ secrets.WS_TASKS_SECRET_KEY }} | |
| - name: Deploy | |
| env: | |
| ENV: ${{ vars.ENV }} | |
| WS_DOCKER_REGISTRY: ${{ vars.WS_DOCKER_REGISTRY }} | |
| # machine to deploy to | |
| AZURE_DOCKER_HOST_IP: ${{ vars.AZURE_DOCKER_HOST_IP }} | |
| # tag to deploy | |
| WS_DOCKER_TAG: ${{ env.CODE_VERSION }} | |
| # passwords | |
| WS_API_DB_PASS: ${{ secrets.WS_API_DB_PASS }} | |
| WS_MAPBOX_ACCESS_TOKEN: ${{ secrets.WS_MAPBOX_ACCESS_TOKEN }} | |
| WS_OSM_DB_PASS: ${{ secrets.WS_OSM_DB_PASS }} | |
| WS_OSM_SECRET_KEY_BASE: ${{ secrets.WS_OSM_SECRET_KEY_BASE }} | |
| WS_SMTP_PASS: ${{ secrets.WS_SMTP_PASS }} | |
| WS_TASKS_DB_PASS: ${{ secrets.WS_TASKS_DB_PASS }} | |
| WS_TASKS_SECRET_KEY: ${{ secrets.WS_TASKS_SECRET_KEY }} | |
| run: | | |
| mkdir -p ~/.ssh | |
| eval `ssh-agent -s` | |
| ssh-keyscan ${{ vars.AZURE_DOCKER_HOST_IP }} >> ~/.ssh/known_hosts | |
| echo "${{ secrets.GH_ACTIONS_SSH_KEY }}" > ~/.ssh/github_actions | |
| chmod 600 ~/.ssh/github_actions | |
| ssh-add ~/.ssh/github_actions | |
| docker context create dev --docker "host=ssh://github-actions@${{ vars.AZURE_DOCKER_HOST_IP }}" | |
| docker context use dev | |
| # stop all running images, remove the containers, remove the images | |
| # why? in case we're rebuilding the image of the same commit, we want to ensure the newer image is deployed | |
| # in case the last one was corrupted for some reason--just to avoid any questions about deployment reliability | |
| #docker stop $(docker ps -q) | |
| #docker rm -v $(docker ps --filter status=exited -q) | |
| #docker rmi $(docker images -q) | |
| # remove images no longer in use--may need disk space to pull | |
| # docker image prune -a -f | |
| # pull new images, recreate containers | |
| docker compose -f docker-compose.deploy.yml --env-file tdei_uw.env up -d --force-recreate --remove-orphans | |
| # check what was deployed, just to save in the GH logs | |
| sleep 30s | |
| docker ps | |