Skip to content

Merge pull request #363 from fujaba/fix/courses #140

Merge pull request #363 from fujaba/fix/courses

Merge pull request #363 from fujaba/fix/courses #140

Workflow file for this run

name: Deploy
on:
push:
branches:
- master
tags:
- v*
jobs:
deployment:
name: Deployment Setup
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # for git describe
- name: Set Deployment Options
id: deployment
run: |
case "$GITHUB_REF" in
refs/tags/v*) TAG="${GITHUB_REF##*/}" ;;
*) TAG=latest ;;
esac
echo "Docker Tag: $TAG"
echo "tag=$TAG" >> $GITHUB_OUTPUT
V_VERSION="$(git describe --tags)"
VERSION="${V_VERSION#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Git Describe Version: $VERSION"
outputs:
version: ${{ steps.deployment.outputs.version }}
tag: ${{ steps.deployment.outputs.tag }}
frontend:
name: Frontend
runs-on: ubuntu-latest
needs: [ deployment ]
defaults:
run:
working-directory: frontend
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build the Docker Image
uses: whoan/docker-build-with-cache-action@v6
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ${{ secrets.DOCKER_REGISTRY }}
image_name: fulib/fulib.org-frontend
image_tag: ${{ needs.deployment.outputs.tag }}
context: frontend/
- name: Deploy to Rancher
uses: sekassel-research/[email protected]
with:
rancher_url: ${{ secrets.RANCHER_URL }}
rancher_token: ${{ secrets.RANCHER_TOKEN }}
cluster_id: ${{ secrets.RANCHER_CLUSTER }}
project_id: ${{ secrets.RANCHER_PROJECT }}
namespace: ${{ secrets.NAMESPACE }}
deployment: fulib-frontend
docker_image: ${{ secrets.DOCKER_REGISTRY }}/fulib/fulib.org-frontend:${{ needs.deployment.outputs.tag }}
backend:
name: Backend
runs-on: ubuntu-latest
needs: [ deployment ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build the Backend Docker Image
uses: whoan/docker-build-with-cache-action@v6
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ${{ secrets.DOCKER_REGISTRY }}
image_name: fulib/fulib.org-backend
image_tag: ${{ needs.deployment.outputs.tag }}
context: backend/
build_extra_args: --build-arg VERSION=${{ needs.deployment.outputs.version }}
- name: Deploy the Backend to Rancher
uses: sekassel-research/[email protected]
with:
rancher_url: ${{ secrets.RANCHER_URL }}
rancher_token: ${{ secrets.RANCHER_TOKEN }}
cluster_id: ${{ secrets.RANCHER_CLUSTER }}
project_id: ${{ secrets.RANCHER_PROJECT }}
namespace: ${{ secrets.NAMESPACE }}
deployment: fulib-backend
docker_image: ${{ secrets.DOCKER_REGISTRY }}/fulib/fulib.org-backend:${{ needs.deployment.outputs.tag }}
services:
name: ${{ matrix.service}} Service
runs-on: ubuntu-latest
needs: [ deployment ]
defaults:
run:
working-directory: services
strategy:
matrix:
service:
- projects
- assignments
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build the Docker Image
uses: whoan/docker-build-with-cache-action@v6
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ${{ secrets.DOCKER_REGISTRY }}
image_name: fulib/fulib.org-${{ matrix.service }}-service
image_tag: ${{ needs.deployment.outputs.tag }}
build_extra_args: --build-arg=SERVICE=${{ matrix.service }}
context: services/
- name: Deploy to Rancher
uses: sekassel-research/[email protected]
with:
rancher_url: ${{ secrets.RANCHER_URL }}
rancher_token: ${{ secrets.RANCHER_TOKEN }}
cluster_id: ${{ secrets.RANCHER_CLUSTER }}
project_id: ${{ secrets.RANCHER_PROJECT }}
namespace: ${{ secrets.NAMESPACE }}
deployment: fulib-${{ matrix.service }}-service
docker_image: ${{ secrets.DOCKER_REGISTRY }}/fulib/fulib.org-${{ matrix.service }}-service:${{ needs.deployment.outputs.tag }}
projects-images:
name: Projects Images
runs-on: ubuntu-latest
needs: [ deployment ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker
uses: docker/login-action@v2
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push base
uses: docker/bake-action@v3
with:
push: true
workdir: projects/
files: docker-compose.base.yaml
set: |
*.cache-to=type=gha,mode=max
*.cache-from=type=gha
- name: Build and push techs
uses: docker/bake-action@v3
with:
push: true
workdir: projects/
files: docker-compose.techs.yaml
set: |
*.cache-to=type=gha,mode=max
*.cache-from=type=gha
projects-proxy:
name: Projects Proxy
runs-on: ubuntu-latest
needs: [ deployment ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build the Projects Proxy Docker Image
uses: whoan/docker-build-with-cache-action@v6
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ${{ secrets.DOCKER_REGISTRY }}
image_name: fulib/fulib.org-projects-proxy
image_tag: ${{ needs.deployment.outputs.tag }}
context: projects/
dockerfile: proxy/Dockerfile
projects-runtime:
name: Projects Runtime
runs-on: ubuntu-latest
needs: [ deployment ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build the Projects Runtime Docker Image
uses: whoan/docker-build-with-cache-action@v6
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ${{ secrets.DOCKER_REGISTRY }}
image_name: fulib/fulib.org-projects-runtime
image_tag: ${{ needs.deployment.outputs.tag }}
context: projects/
dockerfile: runtime/Dockerfile
projects-deploy:
name: Projects Deployment
runs-on: ubuntu-latest
needs: [ deployment, projects-images, projects-proxy, projects-runtime ]
steps:
- name: Deploy the Projects Runtime to Rancher
uses: sekassel-research/[email protected]
with:
rancher_url: ${{ secrets.RANCHER_URL }}
rancher_token: ${{ secrets.RANCHER_TOKEN }}
cluster_id: ${{ secrets.RANCHER_CLUSTER }}
project_id: ${{ secrets.RANCHER_PROJECT }}
namespace: ${{ secrets.NAMESPACE }}
deployment: fulib-projects-runtime
docker_image: ${{ secrets.DOCKER_REGISTRY }}/fulib/fulib.org-projects-runtime:${{ needs.deployment.outputs.tag }}