Skip to content

Commit

Permalink
Merge branch 'master' into 4789-finance-negative-balance
Browse files Browse the repository at this point in the history
  • Loading branch information
dogi authored Oct 24, 2023
2 parents 112193c + cb4496e commit 6be01d0
Show file tree
Hide file tree
Showing 383 changed files with 240,547 additions and 43,552 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Manual Deploy

on:
#push:
# branches:
# - deploy
workflow_dispatch:
inputs:
hostname:
description: 'Server hostname Eg. "planet.dev.ole.org"'
required: true
default: 'planet.dev.ole.org'
buildname:
description: 'Planet Image name Eg. "0.13.4-deploy-d6b59441"'
required: false

env:
DOCKER_ORG: treehouses
DOCKER_REPO_TAG: planet-tags
DOCKER_REPO: planet

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v4

- name: sshagent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSHKEY }}

- name: deploy
run: |
if [[ "${{ github.event.inputs.hostname }}" == "" ]]; then
SERVER_HOST="planet.dev.ole.org"
else
SERVER_HOST="${{ github.event.inputs.hostname }}"
fi
PLANET_VERSION=$(jq '.version' package.json | sed -e 's/^"//' -e 's/"$//')
if [[ "${{ github.event.inputs.buildname }}" == "" ]]; then
BUILD="$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}"
# BUILD="0.13.4-deploy-d6b59441"
else
SERVER_HOST="${{ github.event.inputs.hostname }}"
fi
PLANET_REPO="$DOCKER_ORG/$DOCKER_REPO_TAG:$BUILD"
DBINIT_REPO="$DOCKER_ORG/$DOCKER_REPO_TAG:db-init-$BUILD"
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "planet.dev.ole.org ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFqXBJPFe+pH3L57o1ildAxHssG4lpkloTcw3Wbs64c7bL8M6hR0rre4ufpCKboVLn4trJqbKOPWtFgBJHsgqXA=" > ~/.ssh/known_hosts
# echo "planet.earth.ole.org ...."
ssh root@$SERVER_HOST <<EOF
docker pull $PLANET_REPO
docker pull $DBINIT_REPO
docker tag $PLANET_REPO "$DOCKER_ORG/$DOCKER_REPO:local"
docker tag $DBINIT_REPO "$DOCKER_ORG/$DOCKER_REPO:db-init-local"
docker images
treehouses services planet restart
EOF
108 changes: 108 additions & 0 deletions .github/workflows/planet-chat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Planet Chat API Builder

on:
push:
branches-ignore:
- l10n_i18n
release:
types: [published]
workflow_dispatch:

env:
DOCKER_ORG: treehouses
DOCKER_REPO_TAG: planet-tags
DOCKER_REPO: planet

jobs:

build-prepare:
name: Preparing
runs-on: ubuntu-latest
outputs:
planet_version: ${{ steps.step1.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setting Env
id: step1
run: |
version=$(jq '.version' package.json | sed -e 's/^"//' -e 's/"$//')
echo "::set-output name=version::$version"
build:
name: Chat API build
needs: [ build-prepare ]
runs-on: ubuntu-latest
env:
PLANET_VERSION: ${{ needs.build-prepare.outputs.planet_version }}

strategy:
matrix:
arch: [ amd64, arm, arm64 ]

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Docker login
run: docker login -u ${{ secrets.DOCKERUSERNAME }} -p ${{ secrets.DOCKERAPIKEY }}

- name: Build image
run: |
repo="$DOCKER_ORG/$DOCKER_REPO_TAG:${{ matrix.arch }}-chatapi-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}"
branchrepo="$DOCKER_ORG/$DOCKER_REPO_TAG:${{ matrix.arch }}-chatapi-$PLANET_VERSION-$GITHUB_REF_NAME"
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker build -f './docker/chatapi/${{ matrix.arch }}-Dockerfile' -t $repo .
docker images
docker tag $repo $branchrepo
docker push $repo
docker push $branchrepo
multiarch:
name: Manifest build
needs: [ build-prepare, build ]
env:
PLANET_VERSION: ${{ needs.build-prepare.outputs.planet_version }}
runs-on: ubuntu-latest

steps:
- name: Docker login
run: docker login -u ${{ secrets.DOCKERUSERNAME }} -p ${{ secrets.DOCKERAPIKEY }}

- name: Multiarch Deploy
run: |
sudo wget -O /usr/local/bin/manifest_tool https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-amd64
sudo chmod +x /usr/local/bin/manifest_tool
mkdir -p /tmp/MA_manifests
latesttag="$DOCKER_ORG/$DOCKER_REPO_TAG:chatapi-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e -n '.image = strenv(latesttag)' | \
amd64tag="$DOCKER_ORG/$DOCKER_REPO_TAG:amd64-chatapi-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[0].image = strenv(amd64tag)' - | \
yq e '.manifests[0].platform.architecture = "amd64"' - | \
yq e '.manifests[0].platform.os = "linux"' - | \
armtag="$DOCKER_ORG/$DOCKER_REPO_TAG:arm-chatapi-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[1].image = strenv(armtag)' - | \
yq e '.manifests[1].platform.architecture = "arm"' - | \
yq e '.manifests[1].platform.os = "linux"' - | \
arm64tag="$DOCKER_ORG/$DOCKER_REPO_TAG:arm64-chatapi-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[2].image = strenv(arm64tag)' - | \
yq e '.manifests[2].platform.architecture = "arm64"' - | \
yq e '.manifests[2].platform.os = "linux"' - | \
tee /tmp/MA_manifests/MA_chatapi_latest.yaml
manifest_tool push from-spec /tmp/MA_manifests/MA_chatapi_latest.yaml
- name: Multiarch Deploy Versioned
if: ${{ github.event_name == 'release' }}
run: |
sudo wget -O /usr/local/bin/manifest_tool https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-amd64
sudo chmod +x /usr/local/bin/manifest_tool
mkdir -p /tmp/MA_manifests
versiontag="$DOCKER_ORG/$DOCKER_REPO:chatapi-$PLANET_VERSION" yq e -n '.image = strenv(versiontag)' | \
yq e '.tags |= . + ["chatapi"] ' - | \
amd64tag="$DOCKER_ORG/$DOCKER_REPO_TAG:amd64-chatapi-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[0].image = strenv(amd64tag)' - | \
yq e '.manifests[0].platform.architecture = "amd64"' - | \
yq e '.manifests[0].platform.os = "linux"' - | \
armtag="$DOCKER_ORG/$DOCKER_REPO_TAG:arm-chatapi-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[1].image = strenv(armtag)' - | \
yq e '.manifests[1].platform.architecture = "arm"' - | \
yq e '.manifests[1].platform.os = "linux"' - | \
arm64tag="$DOCKER_ORG/$DOCKER_REPO_TAG:arm64-chatapi-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[2].image = strenv(arm64tag)' - | \
yq e '.manifests[2].platform.architecture = "arm64"' - | \
yq e '.manifests[2].platform.os = "linux"' - | \
tee /tmp/MA_manifests/MA_chatapi_versioned.yaml
manifest_tool push from-spec /tmp/MA_manifests/MA_chatapi_versioned.yaml
108 changes: 108 additions & 0 deletions .github/workflows/planet-db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Planet DB-Init Builder

on:
push:
branches-ignore:
- l10n_i18n
release:
types: [published]
workflow_dispatch:

env:
DOCKER_ORG: treehouses
DOCKER_REPO_TAG: planet-tags
DOCKER_REPO: planet

jobs:

build-prepare:
name: Preparing
runs-on: ubuntu-latest
outputs:
planet_version: ${{ steps.step1.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setting Env
id: step1
run: |
version=$(jq '.version' package.json | sed -e 's/^"//' -e 's/"$//')
echo "::set-output name=version::$version"
build:
name: DB Init build
needs: [ build-prepare ]
runs-on: ubuntu-latest
env:
PLANET_VERSION: ${{ needs.build-prepare.outputs.planet_version }}

strategy:
matrix:
arch: [ amd64, arm, arm64 ]

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Docker login
run: docker login -u ${{ secrets.DOCKERUSERNAME }} -p ${{ secrets.DOCKERAPIKEY }}

- name: Build image
run: |
repo="$DOCKER_ORG/$DOCKER_REPO_TAG:${{ matrix.arch }}-db-init-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}"
branchrepo="$DOCKER_ORG/$DOCKER_REPO_TAG:${{ matrix.arch }}-db-init-$PLANET_VERSION-$GITHUB_REF_NAME"
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker build -f './docker/db-init/${{ matrix.arch }}-Dockerfile' -t $repo .
docker images
docker tag $repo $branchrepo
docker push $repo
docker push $branchrepo
multiarch:
name: Manifest build
needs: [ build-prepare, build ]
env:
PLANET_VERSION: ${{ needs.build-prepare.outputs.planet_version }}
runs-on: ubuntu-latest

steps:
- name: Docker login
run: docker login -u ${{ secrets.DOCKERUSERNAME }} -p ${{ secrets.DOCKERAPIKEY }}

- name: Multiarch Deploy
run: |
sudo wget -O /usr/local/bin/manifest_tool https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-amd64
sudo chmod +x /usr/local/bin/manifest_tool
mkdir -p /tmp/MA_manifests
latesttag="$DOCKER_ORG/$DOCKER_REPO_TAG:db-init-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e -n '.image = strenv(latesttag)' | \
amd64tag="$DOCKER_ORG/$DOCKER_REPO_TAG:amd64-db-init-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[0].image = strenv(amd64tag)' - | \
yq e '.manifests[0].platform.architecture = "amd64"' - | \
yq e '.manifests[0].platform.os = "linux"' - | \
armtag="$DOCKER_ORG/$DOCKER_REPO_TAG:arm-db-init-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[1].image = strenv(armtag)' - | \
yq e '.manifests[1].platform.architecture = "arm"' - | \
yq e '.manifests[1].platform.os = "linux"' - | \
arm64tag="$DOCKER_ORG/$DOCKER_REPO_TAG:arm64-db-init-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[2].image = strenv(arm64tag)' - | \
yq e '.manifests[2].platform.architecture = "arm64"' - | \
yq e '.manifests[2].platform.os = "linux"' - | \
tee /tmp/MA_manifests/MA_db-init_latest.yaml
manifest_tool push from-spec /tmp/MA_manifests/MA_db-init_latest.yaml
- name: Multiarch Deploy Versioned
if: ${{ github.event_name == 'release' }}
run: |
sudo wget -O /usr/local/bin/manifest_tool https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-amd64
sudo chmod +x /usr/local/bin/manifest_tool
mkdir -p /tmp/MA_manifests
versiontag="$DOCKER_ORG/$DOCKER_REPO:db-init-$PLANET_VERSION" yq e -n '.image = strenv(versiontag)' | \
yq e '.tags |= . + ["db-init"] ' - | \
amd64tag="$DOCKER_ORG/$DOCKER_REPO_TAG:amd64-db-init-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[0].image = strenv(amd64tag)' - | \
yq e '.manifests[0].platform.architecture = "amd64"' - | \
yq e '.manifests[0].platform.os = "linux"' - | \
armtag="$DOCKER_ORG/$DOCKER_REPO_TAG:arm-db-init-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[1].image = strenv(armtag)' - | \
yq e '.manifests[1].platform.architecture = "arm"' - | \
yq e '.manifests[1].platform.os = "linux"' - | \
arm64tag="$DOCKER_ORG/$DOCKER_REPO_TAG:arm64-db-init-$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}" yq e '.manifests[2].image = strenv(arm64tag)' - | \
yq e '.manifests[2].platform.architecture = "arm64"' - | \
yq e '.manifests[2].platform.os = "linux"' - | \
tee /tmp/MA_manifests/MA_db-init_versioned.yaml
manifest_tool push from-spec /tmp/MA_manifests/MA_db-init_versioned.yaml
Loading

0 comments on commit 6be01d0

Please sign in to comment.