Merge pull request #48 from polyglot-edu/20-new-execution-api-concept #37
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: Build and Deploy | |
on: | |
push: | |
branches: [dev] | |
jobs: | |
build: | |
permissions: write-all | |
name: Build and Deploy | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to ghcr.io | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata from repository | |
uses: docker/metadata-action@v3 | |
id: meta | |
with: | |
images: ghcr.io/${{ github.repository }} | |
- name: Build and push to ghcr.io | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: false | |
load: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
no-cache: true | |
# cache-from: type=gha | |
# cache-to: type=gha,mode=max | |
- name: Push to ghcr.io with retries | |
uses: nick-invision/retry@v2 | |
with: | |
timeout_minutes: 5 | |
max_attempts: 5 | |
command: echo "${{ steps.meta.outputs.tags }}" | while IFS= read -r i; do echo "Pushing $i"; docker push $i; done | |
- name: Deploy to Kubernetes cluster | |
uses: daviFrag/helm@master | |
with: | |
release: 'polyglot-backend-staging' | |
namespace: 'polyglot-backend-staging' | |
chart: 'charts' | |
token: '${{ github.token }}' | |
values: | | |
url: polyglot-api-staging.polyglot-edu.com | |
cfOriginKey: ${{ secrets.CFORIGIN }} | |
dockerconfigjson: ${{ secrets.DOCKER_CONFIG }} | |
image: | |
repository: ${{ steps.meta.outputs.tags }} | |
env: | |
PORT: 5000 | |
mongodbUri: '${{ secrets.MONGODB_URI }}' | |
authAudience: ${{ secrets.AUTH0_AUDIENCE }} | |
authIssuerUrl: ${{ secrets.AUTH0_ISSUER_BASE_URL }} | |
openAiSecret: secret | |
openAiEndpoint: domain | |
testMode: true | |
apiKey: '${{ secrets.APIKEY }}' | |
AIGENERATION: '${{ secrets.AIGENERATION }}' | |
env: | |
KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}' |