Build Theia IDE Preview Image #19
Workflow file for this run
This file contains hidden or 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: Publish Theia IDE Preview Deployment | |
| permissions: | |
| contents: read | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: The image's tag | |
| required: true | |
| default: next | |
| theia_version: | |
| description: Theia Version | |
| required: false | |
| default: next | |
| pull_request: | |
| branches: [master] | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| schedule: | |
| - cron: '0 13 * * 0' | |
| jobs: | |
| build: | |
| name: Build Theia IDE Preview image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1 | |
| - name: Set the Theia version | |
| id: set-theia-version | |
| run: | | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
| echo "THEIA_VERSION=${{ github.event.inputs.theia_version }}" >> $GITHUB_ENV | |
| elif [ "${{ github.event_name }}" == "pull_request" ]; then | |
| echo "THEIA_VERSION=" >> $GITHUB_ENV | |
| else | |
| echo "THEIA_VERSION=next" >> $GITHUB_ENV | |
| fi | |
| - name: Run Theia update if version is specified | |
| if: ${{ env.THEIA_VERSION != '' }} | |
| run: | | |
| yarn && yarn update:theia ${THEIA_VERSION} && yarn update:theia:children ${THEIA_VERSION} && yarn | |
| - name: Set image tag | |
| id: set-tag | |
| run: | | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
| echo "IMAGE_TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV | |
| elif [ "${{ github.event_name }}" == "pull_request" ]; then | |
| echo "IMAGE_TAG=pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV | |
| elif [ "${{ github.event_name }}" == "schedule" ]; then | |
| echo "IMAGE_TAG=weekly" >> $GITHUB_ENV | |
| else | |
| echo "IMAGE_TAG=other" >> $GITHUB_ENV | |
| fi | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@71f986410dfbc7added4569d411d040a91dc6935 # v2.1.8 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SA_KEY }} | |
| project_id: kubernetes-238012 | |
| create_credentials_file: true | |
| - name: Setup Google Cloud SDK | |
| uses: google-github-actions/setup-gcloud@77e7a554d41e2ee56fc945c52dfd3f33d12def9a # v2.1.4 | |
| - name: Configure Docker for Artifact Registry | |
| run: | | |
| gcloud auth configure-docker europe-west3-docker.pkg.dev | |
| #- name: Build Docker image | |
| # uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0 | |
| # with: | |
| # context: . | |
| # file: browser.Dockerfile | |
| # push: true | |
| # tags: | | |
| # europe-west3-docker.pkg.dev/kubernetes-238012/theia-ide-preview/theia-ide-preview:${{ env.IMAGE_TAG }} | |
| - name: Get GKE Credentials | |
| uses: google-github-actions/get-gke-credentials@d0cee45012069b163a631894b98904a9e6723729 # v2.3.3 | |
| with: | |
| cluster_name: github-theia-ide-preview | |
| location: europe-west3-c | |
| - name: List sessions in theia-cloud namespace | |
| run: kubectl get sessions -n theia-cloud | |
| - name: List apps in theia-cloud namespace | |
| run: kubectl get appdefinitions -n theia-cloud | |
| - name: Delete app definition if existent | |
| run: kubectl delete appdefinitions theia-ide-${{ env.IMAGE_TAG }} -n theia-cloud || true | |
| - name: Delete existing sessions | |
| run: kubectl get sessions -n theia-cloud -o json | jq -r '.items[] | select(.spec.appDefinition == "theia-ide-${{ env.IMAGE_TAG }}") | .metadata.name' | xargs -r kubectl delete sessions -n theia-cloud | |
| - name: Create app definition | |
| run: | | |
| cat <<EOF | kubectl apply -f - | |
| apiVersion: theia.cloud/v1beta10 | |
| kind: AppDefinition | |
| metadata: | |
| name: theia-ide-${{ env.IMAGE_TAG }} | |
| namespace: theia-cloud | |
| spec: | |
| downlinkLimit: 30000 | |
| image: europe-west3-docker.pkg.dev/kubernetes-238012/theia-ide-preview/theia-ide-preview:${{ env.IMAGE_TAG }} | |
| imagePullPolicy: Always | |
| ingressname: theia-cloud-demo-ws-ingress | |
| limitsCpu: "2" | |
| limitsMemory: 500M | |
| maxInstances: 3 | |
| minInstances: 0 | |
| mountPath: /home/project/persisted | |
| name: theia-ide-${{ env.IMAGE_TAG }} | |
| port: 3000 | |
| requestsCpu: "100m" | |
| requestsMemory: 300M | |
| timeout: 15 | |
| uid: 101 | |
| uplinkLimit: 30000 | |
| EOF |