Release #67
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: Image Build | |
| 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: Generate release notes | |
| run: | |
| ./gen-rel-notes.sh > CHANGELOG | |
| - name: Cache Docker layers | |
| uses: actions/cache@v4 | |
| with: | |
| path: /tmp/.buildx-cache-app | |
| key: ${{ runner.os }}-buildx-app-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-buildx-app | |
| - name: Prepare for buildx | |
| run: | | |
| cp tdei_uw.env .env | |
| echo "CODE_VERSION=${CODE_VERSION}" >> .env | |
| - name: Build and push | |
| uses: docker/[email protected] | |
| 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 }} | |
| with: | |
| files: docker-buildx.build.hcl | |
| push: true | |
| set: | | |
| *.cache-from=type=local,src=/tmp/.buildx-cache | |
| *.cache-to=type=local,mode=max,dest=/tmp/.buildx-cache-new | |
| allow: | |
| "fs=/tmp" | |
| #- name: Build and push | |
| # run: | | |
| # cp tdei_uw.env .env | |
| # echo "CODE_VERSION=${CODE_VERSION}" >> .env | |
| # docker buildx bake -f docker-compose.build.yml --push #--set '*.cache-from=type=local,src=/tmp/.buildx-cache-app' --set #'*.cache-to=type=local,dest=/tmp/.buildx-cache-app-new,mode=max' --allow=fs=/tmp | |
| # 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: Prepare cache | |
| run: | | |
| rm -rf /tmp/.buildx-cache-app # Remove the old cache. | |
| mv /tmp/.buildx-cache-app-new /tmp/.buildx-cache-app # Move the new cache to replace the old cache. | |
| - 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 | |
| # 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 | |