[WIP] Addition of Helm Charts For K8S #35
Workflow file for this run
This file contains 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: Building Docker Images | |
on: [push,pull_request] | |
# pull_request: | |
# branches: | |
# - 'release' | |
# - 'master' | |
# push: | |
# branches: | |
# - 'release' | |
# - 'master' | |
jobs: | |
generate-semantic-version: | |
runs-on: ubuntu-latest | |
container: | |
image: gittools/gitversion | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Run GitVersion | |
run: /tools/dotnet-gitversion /output buildserver | |
- name: Saving Results | |
run: | | |
REPOSITORY_LC=$(echo "$REPOSITORY" | tr '[:upper:]' '[:lower:]') | |
GitVersion_FullSemVer_Docker=$(echo "$GitVersion_FullSemVer" | tr '+' '.') | |
echo "GitVersion_FullSemVer_Docker=$GitVersion_FullSemVer_Docker" >> gitversion.properties | |
echo "GitVersion_FullSemVer=$GitVersion_FullSemVer" >> gitversion.properties | |
echo "GitVersion_LegacySemVer=$GitVersion_LegacySemVer" >> gitversion.properties | |
echo "GitVersion_Major=$GitVersion_Major" >> gitversion.properties | |
echo "GitVersion_MajorMinorPatch=$GitVersion_MajorMinorPatch" >> gitversion.properties | |
echo "GitVersion_Minor=$GitVersion_Minor" >> gitversion.properties | |
echo "GitVersion_Patch=$GitVersion_Patch" >> gitversion.properties | |
echo "GitVersion_PreReleaseLabel=$GitVersion_PreReleaseLabel" >> gitversion.properties | |
echo "GitVersion_PreReleaseNumber=$GitVersion_PreReleaseNumber" >> gitversion.properties | |
echo "GitVersion_SemVer=$GitVersion_SemVer" >> gitversion.properties | |
echo "REPOSITORY_LC=$REPOSITORY_LC" >> gitversion.properties | |
env: | |
REPOSITORY: '${{ github.repository }}' | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: gitversion.properties | |
path: gitversion.properties | |
build-base-image: | |
runs-on: ubuntu-latest | |
needs: | |
- generate-semantic-version | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: gitversion.properties | |
- name: Load Variables | |
run: cat gitversion.properties >> $GITHUB_ENV | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and Push | |
uses: docker/build-push-action@v5 | |
with: | |
cache-from: | | |
thespaghettidetective/web:base-1.13 | |
thespaghettidetective/web:base | |
ghcr.io/${{ env.REPOSITORY_LC }}/web:base-1.13 | |
ghcr.io/${{ env.REPOSITORY_LC }}/web:base | |
context: backend | |
file: backend/Dockerfile.base | |
tags: ghcr.io/${{ env.REPOSITORY_LC }}/web:base-${{ env.GitVersion_FullSemVer_Docker }} | |
outputs: type=docker,dest=/tmp/web-base.image.tar | |
push: false | |
- name: Upload Image | |
uses: actions/upload-artifact@v3 | |
with: | |
name: web-base.image.tar | |
path: /tmp/web-base.image.tar | |
build-base-ml-image: | |
runs-on: ubuntu-latest | |
needs: | |
- generate-semantic-version | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: gitversion.properties | |
- name: Load Variables | |
run: cat gitversion.properties >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and Push | |
uses: docker/build-push-action@v5 | |
with: | |
cache-from: | | |
thespaghettidetective/ml_api_base:1.3 | |
thespaghettidetective/ml_api_base | |
ghcr.io/${{ env.REPOSITORY_LC }}/ml_api_base:1.3 | |
ghcr.io/${{ env.REPOSITORY_LC }}/ml_api_base | |
context: ml_api | |
file: ml_api/Dockerfile.base_amd64 | |
tags: ghcr.io/${{ env.REPOSITORY_LC }}/ml_api_base:base-${{ env.GitVersion_FullSemVer_Docker }} | |
outputs: type=docker,dest=/tmp/ml-api-base.image.tar | |
push: false | |
- name: Upload Image | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ml-api-base.image.tar | |
path: /tmp/ml-api-base.image.tar | |
build-backend-image: | |
runs-on: ubuntu-latest | |
needs: | |
- build-base-image | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: gitversion.properties | |
- name: Load Variables | |
run: cat gitversion.properties >> $GITHUB_ENV | |
- name: Download Web Base | |
uses: actions/download-artifact@v3 | |
with: | |
name: web-base.image.tar | |
path: /tmp | |
- name: Load Web Base | |
run: | | |
set -e | |
docker load --input /tmp/web-base.image.tar | |
docker image ls -a | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and export | |
uses: docker/build-push-action@v5 | |
with: | |
cache-from: | | |
thespaghettidetective/server:base-1.13 | |
thespaghettidetective/server:base | |
ghcr.io/${{ env.REPOSITORY_LC }}/server:base-1.13 | |
ghcr.io/${{ env.REPOSITORY_LC }}/server:base | |
context: . | |
file: backend/Dockerfile | |
tags: ghcr.io/${{ env.REPOSITORY_LC }}/server:${{ env.GitVersion_FullSemVer_Docker }} | |
outputs: type=docker,dest=/tmp/web.image.tar | |
push: false | |
- name: Upload Image | |
uses: actions/upload-artifact@v3 | |
with: | |
name: web.image.tar | |
path: /tmp/web.image.tar | |
build-api-image: | |
runs-on: ubuntu-latest | |
needs: | |
- build-base-ml-image | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: gitversion.properties | |
- name: Load Variables | |
run: cat gitversion.properties >> $GITHUB_ENV | |
- name: Download ML API Base | |
uses: actions/download-artifact@v3 | |
with: | |
name: ml-api-base.image.tar | |
path: /tmp | |
- name: Load ML API Base | |
run: | | |
set -e | |
docker load --input /tmp/ml-api-base.image.tar | |
docker image ls -a | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and export | |
uses: docker/build-push-action@v5 | |
with: | |
cache-from: | | |
thespaghettidetective/ml:base-1.13 | |
thespaghettidetective/ml:base | |
ghcr.io/${{ env.REPOSITORY_LC }}/ml:base-1.13 | |
ghcr.io/${{ env.REPOSITORY_LC }}/ml:base | |
context: ml_api | |
file: ml_api/Dockerfile | |
tags: ghcr.io/${{ env.REPOSITORY_LC }}/ml:${{ env.GitVersion_FullSemVer_Docker }} | |
outputs: type=docker,dest=/tmp/ml-api.image.tar | |
- name: Upload Image | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ml-api.image.tar | |
path: /tmp/ml-api.image.tar | |
build-helm-package: | |
runs-on: ubuntu-latest | |
needs: | |
- build-backend-image | |
- build-api-image | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.13.0 | |
- uses: actions/download-artifacts@v3 | |
with: | |
name: gitversion.properties | |
- name: Load Variables | |
run: cat gitversion.properties >> $GITHUB_ENV | |
- name: Update Web Image | |
run: sed -i "s#thespaghettidetective/web#thespaghettidetective/web:${{ env.GitVersion_FullSemVer }}#" helm/values.yaml | |
- name: Update ML API Image | |
run: | | |
set -e | |
sed -i "s#thespaghettidetective/ml_api#thespaghettidetective/ml_api:${{ env.GitVersion_FullSemVer }}#" helm/values.yaml | |
- name: Update Chart Version | |
run: | | |
set -e | |
sed -i "s#version: 0.0.0#version: ${{ env.GitVersion_FullSemVer }}#" helm/Chart.yaml | |
- name: Package Helm | |
run: helm package helm --version=${{ env.GitVersion_FullSemVer }} | |
- uses: actions/upload-artifacts@v3 | |
with: | |
name: obico-helm-package | |
path: obico-${{ env.GitVersion_FullSemVer }}.tgz | |
test-helm-package: | |
runs-on: ubuntu-latest | |
needs: | |
- build-helm-package | |
steps: | |
- name: Download ML API Base | |
uses: actions/download-artifact@v3 | |
with: | |
name: ml-api-base.image.tar | |
path: /tmp | |
- name: Download Web Base | |
uses: actions/download-artifact@v3 | |
with: | |
name: web-base.image.tar | |
path: /tmp | |
- name: Download ML API | |
uses: actions/download-artifact@v3 | |
with: | |
name: ml-api.image.tar | |
path: /tmp | |
- name: Download Web | |
uses: actions/download-artifact@v3 | |
with: | |
name: web.image.tar | |
path: /tmp | |
- name: Load ML API Base | |
run: | | |
set -e | |
docker load --input /tmp/ml-api-base.image.tar | |
docker image ls -a | |
- name: Load Web Base | |
run: | | |
set -e | |
docker load --input /tmp/web-base.image.tar | |
docker image ls -a | |
- name: Load ML API | |
run: | | |
set -e | |
docker load --input /tmp/ml-api.image.tar | |
docker image ls -a | |
- name: Load Web | |
run: | | |
set -e | |
docker load --input /tmp/web.image.tar | |
docker image ls -a | |
upload-packages: | |
#if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
needs: | |
- test-helm-package | |
steps: | |
- name: Download ML API | |
uses: actions/download-artifact@v3 | |
with: | |
name: ml-api.image.tar | |
path: /tmp | |
- name: Download Web | |
uses: actions/download-artifact@v3 | |
with: | |
name: web.image.tar | |
path: /tmp | |
- name: Load ML API | |
run: | | |
set -e | |
docker load --input /tmp/ml-api.image.tar | |
docker image ls -a | |
- name: Load Web | |
run: | | |
set -e | |
docker load --input /tmp/web.image.tar | |
docker image ls -a | |
- name: Download ML API Base | |
uses: actions/download-artifact@v3 | |
with: | |
name: ml-api-base.image.tar | |
path: /tmp | |
- name: Load ML API Base | |
run: | | |
set -e | |
docker load --input /tmp/ml-api-base.image.tar | |
docker image ls -a | |
- name: Download Web Base | |
uses: actions/download-artifact@v3 | |
with: | |
name: web-base.image.tar | |
path: /tmp | |
- name: Load Web Base | |
run: | | |
set -e | |
docker load --input /tmp/web-base.image.tar | |
docker image ls -a | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push | |
uses: docker/build-push-action@v5 | |
with: | |
cache-from: | | |
thespaghettidetective/web:base-1.13 | |
thespaghettidetective/web:base | |
ghcr.io/${{ env.REPOSITORY_LC }}/web:base-1.13 | |
ghcr.io/${{ env.REPOSITORY_LC }}/web:base | |
context: backend | |
file: backend/Dockerfile.base | |
tags: ghcr.io/${{ env.REPOSITORY_LC }}/web:base-${{ env.GitVersion_FullSemVer_Docker }} | |
- name: Build and Push | |
uses: docker/build-push-action@v5 | |
with: | |
cache-from: | | |
thespaghettidetective/ml_api_base:1.3 | |
thespaghettidetective/ml_api_base | |
ghcr.io/${{ env.REPOSITORY_LC }}/ml_api_base:1.3 | |
ghcr.io/${{ env.REPOSITORY_LC }}/ml_api_base | |
context: ml_api | |
file: ml_api/Dockerfile.base_amd64 | |
tags: ghcr.io/${{ env.REPOSITORY_LC }}/ml_api_base:base-${{ env.GitVersion_FullSemVer_Docker }} | |
- name: Build and Push | |
uses: docker/build-push-action@v5 | |
with: | |
cache-from: | | |
thespaghettidetective/server:base-1.13 | |
thespaghettidetective/server:base | |
ghcr.io/${{ env.REPOSITORY_LC }}/server:base-1.13 | |
ghcr.io/${{ env.REPOSITORY_LC }}/server:base | |
context: backend | |
file: backend/Dockerfile | |
push: true | |
tags: ghcr.io/${{ env.REPOSITORY_LC }}/server:${{ env.GitVersion_FullSemVer_Docker }} | |
- name: Build and Push | |
uses: docker/build-push-action@v5 | |
with: | |
cache-from: | | |
thespaghettidetective/ml:base-1.13 | |
thespaghettidetective/ml:base | |
ghcr.io/${{ env.REPOSITORY_LC }}/ml:base-1.13 | |
ghcr.io/${{ env.REPOSITORY_LC }}/ml:base | |
context: ml_api | |
file: ml_api/Dockerfile | |
push: true | |
tags: ghcr.io/${{ env.REPOSITORY_LC }}/ml:${{ env.GitVersion_FullSemVer_Docker }} |