Skip to content

Bump actions/download-artifact from 2 to 4.1.7 in /.github/workflows #251

Bump actions/download-artifact from 2 to 4.1.7 in /.github/workflows

Bump actions/download-artifact from 2 to 4.1.7 in /.github/workflows #251

Workflow file for this run

name: Model CI
on:
push:
branches:
- 'master'
pull_request:
types: [opened, synchronize, reopened]
env:
DOMAIN: 'carbon.rasa.com'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NAME: carbon-assistant
NAMESPACE: carbon-assistant
RASA_X_IMAGE_NAME: ${{ secrets.RASA_X_IMAGE_NAME }}
RASA_X_USERNAME: admin
RASA_X_PASSWORD: ${{ secrets.RASA_X_ADMIN_PASSWORD }}
jobs:
build-model:
name: Build, test, and upload model
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade "pip<20"
pip install -r requirements.txt
- name: Check stories are consistent
run: |
rasa data validate stories --max-history 5 --fail-on-warning
- name: Train model
run: |
rasa train
- name: Run Through Test Stories
run: |
rasa test core --stories test_stories/stories.yml --fail-on-prediction-errors
- name: Cross-validate NLU model
id: cvnlu
if: github.event_name == 'pull_request'
run: |
rasa test nlu -f 2 --cross-validation
python format_results.py
- name: Upload Cross Validation Results
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v2
with:
name: cross-validation-result
path: results.md
- name: Upload model
if: github.event_name == 'push' && (startsWith(github.event.ref, 'refs/tags') || github.ref == 'refs/heads/master')
uses: actions/upload-artifact@v2
with:
name: model
path: models
- name: Post cross-val results to PR
if: steps.cvnlu.outcome == 'success'
uses: samsucik/comment-on-pr@comment-file-contents
continue-on-error: true
with:
msg: results.md
build-images:
name: Build and Push Images
runs-on: ubuntu-latest
env:
IS_PUSH_EVENT: ${{ github.event_name == 'push' }}
steps:
- uses: actions/checkout@v2
- name: Set image tag
run: |
if [[ $IS_PUSH_EVENT == "false" ]]
then
IMAGE_TAG=${{ github.head_ref }}
else
IMAGE_TAG=$(basename ${{ github.ref }})
fi
echo "IMAGE_TAG=${IMAGE_TAG}-${{ github.sha }}" >> $GITHUB_ENV
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@v0.2.1
name: Google Auth
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
# Configure docker to use the gcloud command-line tool as a credential helper
- run: |-
gcloud --quiet auth configure-docker
- name: Build and push the Docker image
run: |
# Read and export variables from .env file
set -o allexport; source .env; set +o allexport
docker build . \
--build-arg RASA_SDK_IMAGE=rasa/rasa-sdk:${RASA_SDK_VERSION} \
--tag gcr.io/${{ secrets.GKE_PROJECT }}/carbon-bot-actions:$IMAGE_TAG
docker push gcr.io/${{ secrets.GKE_PROJECT }}/carbon-bot-actions:$IMAGE_TAG
deploy-to-cluster:
name: Re-deploy the cluster with the latest action server
runs-on: ubuntu-latest
needs:
- build-images
if: github.event_name == 'push' && (startsWith(github.event.ref, 'refs/tags') || github.ref == 'refs/heads/master')
steps:
# Checkout repository because we need the content of the `.env` file later
- uses: actions/checkout@v2
- name: Set image tag
env:
IS_PUSH_EVENT: ${{ github.event_name == 'push' }}
run: |
if [[ $IS_PUSH_EVENT == "false" ]]
then
IMAGE_TAG=${{ github.head_ref }}
else
IMAGE_TAG=$(basename ${{ github.ref }})
fi
echo "IMAGE_TAG=${IMAGE_TAG}-${{ github.sha }}" >> $GITHUB_ENV
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@v0.2.1
name: Google Auth
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
# Configure docker to use the gcloud command-line tool as a credential helper
- run: |-
gcloud --quiet auth configure-docker
# Get the GKE credentials so we can deploy to the cluster
- uses: google-github-actions/get-gke-credentials@v0.2.1
with:
cluster_name: ${{ secrets.GKE_CLUSTER }}
location: ${{ secrets.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}
- name: Install Helm and helmfile ⛑
run: |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
sudo curl -fsSL https://github.com/roboll/helmfile/releases/download/v0.138.7/helmfile_linux_amd64 --output /usr/local/bin/helmfile
sudo chmod +x /usr/local/bin/helmfile
- name: Install Chart
env:
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
RASA_TOKEN: ${{ secrets.RASA_TOKEN }}
RASA_X_TOKEN: ${{ secrets.RASA_X_TOKEN }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
PASSWORD_SALT: ${{ secrets.PASSWORD_SALT }}
REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }}
RABBITMQ_PASSWORD: ${{ secrets.RABBITMQ_PASSWORD }}
RASA_X_ADMIN_PASSWORD: ${{ secrets.RASA_X_ADMIN_PASSWORD }}
GKE_PROJECT: ${{ secrets.GKE_PROJECT }}
FACEBOOK_VERIFY_TOKEN: ${{ secrets.FACEBOOK_VERIFY_TOKEN }}
FACEBOOK_APP_SECRET: ${{ secrets.FACEBOOK_APP_SECRET }}
FACEBOOK_PAGE_ACCESS_TOKEN: ${{ secrets.FACEBOOK_PAGE_ACCESS_TOKEN }}
CLIMATIQ_API_KEY: ${{ secrets.CLIMATIQ_API_KEY }}
run: |
# Install helm v3
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
# Read and export variables from .env file
set -o allexport; source .env; set +o allexport
kubectl create ns ${NAMESPACE} || true
cd .github/deployments; helmfile sync
cat <<EOF | kubectl apply --namespace ${NAMESPACE} -f -
apiVersion: networking.gke.io/v1beta1
kind: ManagedCertificate
metadata:
generation: 1
name: rasa-bots-certificate
spec:
domains:
- ${{ env.DOMAIN }}
EOF
upload-model:
name: Upload the trained model to Rasa X
needs:
- deploy-to-cluster
- build-model
env:
MODEL_DIRECTORY: "models"
if: github.event_name == 'push' && (startsWith(github.event.ref, 'refs/tags') || github.ref == 'refs/heads/master')
runs-on: ubuntu-latest
steps:
- name: Download Model
uses: actions/download-artifact@v4.1.7
with:
name: model
path: ${{ env.MODEL_DIRECTORY }}
- name: Get path to model
run: |
ls -R
echo "MODELNAME=${{ env.MODEL_DIRECTORY }}/$(ls ${{ env.MODEL_DIRECTORY }})" >> $GITHUB_ENV
- name: Upload Model to Rasa
run: |
# Get token
RASA_X_TOKEN=$(curl -s --header "Content-Type: application/json" \
--request POST \
--data "{\"username\":\"${RASA_X_USERNAME}\",\"password\":\"${RASA_X_PASSWORD}\"}" \
https://${{ env.DOMAIN }}/api/auth | jq -r .access_token)
# Upload model
curl -k --fail -H "Authorization: Bearer ${RASA_X_TOKEN}" -F "model=@${MODELNAME}" https://${{ env.DOMAIN }}/api/projects/default/models
# ensure model is ready and tag as production
sleep 5
export MODEL=$(basename ${MODELNAME} .tar.gz)
curl --fail -XPUT -H "Authorization: Bearer ${RASA_X_TOKEN}" https://${{ env.DOMAIN }}/api/projects/default/models/${MODEL}/tags/production