Skip to content

Prepare for prod build--workflow definition for prod branch (#30) #141

Prepare for prod build--workflow definition for prod branch (#30)

Prepare for prod build--workflow definition for prod branch (#30) #141

Workflow file for this run

name: "Release"
on:
push:
branches:
- dev
- stage
- prod
workflow_dispatch:
inputs:
build_flag:
description: 'Docker Build Flags'
default: ''
type: choice
options:
- ''
- '--no-cache'
jobs:
build:
runs-on: ubuntu-latest
name: Build, Push, Deploy
environment: ${{ github.ref_name }}
timeout-minutes: 30
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 up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
run: |
docker compose -f docker-compose.build.yml --env-file tdei_uw.env build --build-arg CODE_VERSION=${CODE_VERSION} ${{github.event.inputs.build_flag}}
docker compose -f docker-compose.build.yml --env-file tdei_uw.env push
env:
ENV: ${{ vars.ENV }}
CODE_VERSION: ${{ github.sha }}
ENV_NAME_PARAM: "${{ vars.ENV == 'prod' && '' || -${ENV} }}"

Check failure on line 46 in .github/workflows/build.yaml

View workflow run for this annotation

GitHub Actions / Release

Invalid workflow file

The workflow is not valid. .github/workflows/build.yaml (Line: 46, Col: 31): Unexpected symbol: '-${ENV}'. Located at position 29 within expression: vars.ENV == 'prod' && '' || -${ENV} .github/workflows/build.yaml (Line: 65, Col: 31): Unexpected symbol: '-${ENV}'. Located at position 29 within expression: vars.ENV == 'prod' && '' || -${ENV}
# hosts
WS_DOCKER_REGISTRY: ${{ vars.WS_DOCKER_REGISTRY }}
WS_POSM_DB_HOST: ${{ vars.WS_POSM_DB_HOST }}
# 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 }}
CODE_VERSION: ${{ github.sha }}
ENV_NAME_PARAM: "${{ vars.ENV == 'prod' && '' || -${ENV} }}"
# machine to deploy to
AZURE_DOCKER_HOST_IP: ${{ vars.AZURE_DOCKER_HOST_IP }}
# tag to deploy
WS_DOCKER_TAG: ${{ github.sha }}
# hosts
WS_DOCKER_REGISTRY: ${{ vars.WS_DOCKER_REGISTRY }}
WS_POSM_DB_HOST: ${{ vars.WS_POSM_DB_HOST }}
# 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
echo Starting SSH agent
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
echo Configuring docker context
docker context create ${{ vars.ENV }} --docker "host=ssh://github-actions@${{ vars.AZURE_DOCKER_HOST_IP }}"
docker context use ${{ vars.ENV }}
# remove images no longer in use--may need disk space to pull
echo Pruning old docker images
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
echo Waiting for deployment to complete
sleep 30s
echo Deploy list
docker ps