Skip to content

changed cell voltage to mV #265

changed cell voltage to mV

changed cell voltage to mV #265

Workflow file for this run

name: Build and Deploy
on:
push:
branches:
workflow_dispatch:
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
concurrency: production
jobs:
frontend:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Github containers
uses: docker/login-action@v2
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
- name: Extract metadata for frontend
id: meta-frontend
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}-frontend
- name: Build and push frontend
uses: docker/build-push-action@v4
with:
push: true
context: ./frontend
build-args: |
"PUBLIC_URL=/dev/${{ github.ref_name }}/frontend"
file: ./frontend/Dockerfile
target: production
tags: ${{ steps.meta-frontend.outputs.tags }}
labels: ${{ steps.meta-frontend.outputs.labels }}
backend:
runs-on: ubuntu-latest
permissions:
packages: write
env:
DB_HOST: ${{ secrets.DB_HOST }}
DB_PASS: ${{ secrets.DB_PASS }}
DB_PORT: ${{ secrets.DB_PORT }}
DB_USER: ${{ secrets.DB_USER }}
DB_DATABASE: ${{ github.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Github containers
uses: docker/login-action@v2
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
- name: Extract metadata for backend
id: meta-backend
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}-backend
- name: Build and push backend
uses: docker/build-push-action@v4
with:
push: true
context: ./backend
file: ./backend/Dockerfile
target: production
tags: ${{ steps.meta-backend.outputs.tags }}
labels: ${{ steps.meta-backend.outputs.labels }}
cs-http:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Github containers
uses: docker/login-action@v2
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
- name: Extract metadata for Chirpstack HTTP
id: meta-cs
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}-cs-http
- name: Build and push Chirpstack HTTP Integration
uses: docker/build-push-action@v3
with:
push: true
file: cs-http.Dockerfile
tags: ${{ steps.meta-cs.outputs.tags }}
labels: ${{ steps.meta-cs.outputs.labels }}
http-api:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Github containers
uses: docker/login-action@v2
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
- name: Extract metadata for HTTP API
id: meta-http-api
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}-http-api
- name: Build and push HTTP API
uses: docker/build-push-action@v3
with:
push: true
file: http-api.Dockerfile
tags: ${{ steps.meta-http-api.outputs.tags }}
labels: ${{ steps.meta-http-api.outputs.labels }}
deploy:
runs-on: ubuntu-latest
needs: [frontend, backend, cs-http, http-api]
environment: ${{ github.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup SSH
run: |
mkdir -p ~/.ssh/
echo "$SERVER_SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "$SERVER_SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
chmod 600 ~/.ssh/known_hosts
env:
SERVER_SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SERVER_SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
shell: bash
- name: Generate frontend.yaml
uses: cuchi/[email protected]
with:
template: k8s/frontend.yaml.j2
output_file: k8s/frontend.yaml
variables: |
hostname=${{ secrets.HOSTNAME }}
- name: Generate backend.yaml
uses: cuchi/[email protected]
with:
template: k8s/backend.yaml.j2
output_file: k8s/backend.yaml
variables: |
hostname=${{ secrets.HOSTNAME }}
- name: Generate http-api.yaml
uses: cuchi/[email protected]
with:
template: k8s/http-api.yaml.j2
output_file: k8s/http-api.yaml
- name: Generate cs-http.yaml
uses: cuchi/[email protected]
with:
template: k8s/cs-http.yaml.j2
output_file: k8s/cs-http.yaml
- name: Generate dburl-secret.yaml
uses: cuchi/[email protected]
with:
template: k8s/dburl-secret.yaml.j2
output_file: k8s/dburl-secret.yaml
strict: true
variables: |
user=${{ secrets.DB_USER }}
pass=${{ secrets.DB_PASS }}
host=${{ secrets.DB_HOST }}
port=${{ secrets.DB_PORT }}
- name: Apply configurations
shell: bash
run: cat k8s/*.yaml | ssh ${{ secrets.USER }}@${{ secrets.HOSTNAME }} '/snap/bin/microk8s kubectl apply -f -'
apply_db_migrations:
runs-on: ubuntu-latest
needs: [frontend, backend, cs-http, http-api]
environment: ${{ github.ref_name }}
env:
DB_HOST: ${{ secrets.DB_HOST }}
DB_PASS: ${{ secrets.DB_PASS }}
DB_PORT: ${{ secrets.DB_PORT }}
DB_USER: ${{ secrets.DB_USER }}
DB_DATABASE: ${{ github.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run migrations
run: flask --app backend.api db upgrade -d ./backend/api/migrations