ci: Fix source-root and use sparse checkout instead #144
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: Deploy | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- v* | |
paths-ignore: | |
- 'projects/**' | |
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 }} |