Deploy shiny app #17
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 shiny app | |
on: | |
workflow_dispatch: | |
inputs: | |
name: | |
description: "Nom du chart à déployer" | |
type: string | |
required: true | |
default: test | |
username: | |
description: Onyxia username | |
type: string | |
required: true | |
default: ananda | |
refreshToken: | |
description: Refresh token" | |
type: string | |
required: true | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: yq - portable yaml processor | |
uses: mikefarah/[email protected] | |
- name: Set image name | |
run: echo "IMAGE_NAME=$(yq '.shiny.image.repository' ./charts/values.yaml)" >> $GITHUB_ENV | |
- name: Image name | |
run: | | |
echo ${{ env.IMAGE_NAME }} | |
- name: Docker meta | |
id: docker_meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: ${{ env.IMAGE_NAME }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./app/ | |
file: ./app/Dockerfile | |
push: true | |
tags: ${{ env.IMAGE_NAME }}:latest | |
labels: ${{ steps.docker_meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} | |
deploy: | |
needs: docker | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.inputs.environment_name }} | |
steps: | |
- name: Mask token | |
run: | | |
REFRESH_TOKEN=$(jq -r '.inputs.refreshToken' $GITHUB_EVENT_PATH) | |
echo ::add-mask::$REFRESH_TOKEN | |
echo REFRESH_TOKEN=$REFRESH_TOKEN >> $GITHUB_ENV | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: azure/setup-kubectl@v3 | |
with: | |
version: 'v1.29.1' | |
id: install_kubectl | |
- uses: azure/[email protected] | |
with: | |
version: '3.14.4' | |
id: install_helm | |
- name: Set credentials | |
run : | | |
kubectl config set-cluster apiserver.kub.sspcloud.fr \ | |
--server=https://apiserver.kub.sspcloud.fr \ | |
--insecure-skip-tls-verify=true | |
kubectl config set-credentials ${{ github.event.inputs.username }} \ | |
--auth-provider=oidc \ | |
--auth-provider-arg=idp-issuer-url=https://auth.lab.sspcloud.fr/auth/realms/sspcloud \ | |
--auth-provider-arg=client-id=onyxia \ | |
--auth-provider-arg=refresh-token=${{ env.REFRESH_TOKEN }} | |
kubectl config set-context apiserver.kub.sspcloud.fr \ | |
--user=${{ github.event.inputs.username }} \ | |
--cluster=apiserver.kub.sspcloud.fr \ | |
--namespace=user-${{ github.event.inputs.username }} | |
kubectl config use-context apiserver.kub.sspcloud.fr | |
- name: "Deploy helm charts" | |
run : | | |
helm dependency update ./charts | |
helm upgrade ${{ github.event.inputs.name }} ./charts --recreate-pods --install |