GitHub Custom Action failure: unexpected token `|', conditional binary operator expected

Hello,

I used this and this to create the GitHub action below:

on:
  push:
    branches:
      - main
    paths:
      - 'actions/**'


jobs:
  training-testing:
    name: Training and Testing
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      
      - name: Rasa Train and Test GitHub Action
        uses: RasaHQ/rasa-train-test-gha@main
        with:
          requirements_file: 'actions/requirements-actions.txt'
          data_validate: true
          rasa_train: true
          cross_validation: true
          rasa_test: true
          test_type: all
          publish_summary: true
          github_token: ${{ secrets.GITHUB_TOKEN }}

      - name: Upload model
        if: github.ref == 'refs/heads/main'
        uses: actions/upload-artifact@main
        with:
          name: model
          path: models

  build_and_deploy:
    name: Build Action Server image and upgrade Rasa X deployment
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2

    - id: action_server
      name: Build an action server with custom actions
      uses: RasaHQ/action-server-gha@main
      with:
        actions_directory: 'actions'
        requirements_file: 'actions/requirements-actions.txt'
        docker_image_name: 'chrisrahme/fyp-chatbot'
        docker_registry_login: ${{ secrets.DOCKER_HUB_LOGIN }}
        docker_registry_password: ${{ secrets.DOCKER_HUB_PASSWORD }}
        docker_image_tag: ${{ github.sha }}

    - name: "Upgrade a Rasa X deployment"
      run: |
        helm upgrade --install --reuse-values \
          --set app.name=${{ steps.action_server.outputs.docker_image_name }} \
          --set app.tag=${{ steps.action_server.outputs.docker_image_tag }} rasa rasa-x/rasa-x

When I update anything inside the actions folder and go to the “Actions” tab of my repository, the GitHub Action runs “Training and Testing” and then fails like so when in “Build Action Server Image”:

I’m new to GitHub actions, I don’t know if this error is my fault or not. In any case, is there a way to fix it, and how? I am currently using the docker build and docker push commands, but it would be way better to use a GitHub Action.

Hi,

At the first glance, the definition of the GH action looks good.

You can enable step debug logging, then you should see more information.

Also, make sure that your docker password doesn’t contain special characters like e.g. |.

BTW, you don’t need actions_directory: 'actions', default value for the actions_directory input parameter is actions, so you can skip it.

1 Like

Wow you’re awesome, thanks a lot @tczekajlo. Turned out it was my Docker password indeed.

But I’ve run into another problem when the Action tries to run helm upgrade:

Run helm upgrade --install --reuse-values \
  --set app.name=docker.io/***/fyp-chatbot \
  --set app.tag=0d5b346bf67fd93c49b342717210e14a5f7800e6 rasa rasa-x/rasa-x
shell: /bin/bash -e {0}
env:
  DOCKERFILE: /home/runner/work/_actions/RasaHQ/action-server-gha/main/default_files/Dockerfile
  DOCKER_IMAGE_FULL_NAME: docker.io/***/fyp-chatbot:0d5b346bf67fd93c49b342717210e14a5f7800e6
  RASA_SDK_VERSION: 2.3.1
Error: Kubernetes cluster unreachable: Get "http://localhost:8080/version?timeout=32s": dial tcp [::1]:8080: connect: connection refused
Error: Process completed with exit code 1.

When I enter that command directly on the server, it works fine:

$ helm upgrade --install --reuse-values --set app.name=docker.io/chrisrahme/fyp-chatbot --set app.tag=0d5b346bf67fd93c49b342717210e14a5f7800e6 rasa rasa-x/rasa-x

WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /etc/rancher/k3s/k3s.yaml
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /etc/rancher/k3s/k3s.yaml
Release "rasa" has been upgraded. Happy Helming!
NAME: rasa
LAST DEPLOYED: Wed Feb 17 14:14:36 2021
NAMESPACE: rasa
STATUS: deployed
REVISION: 27
TEST SUITE: None
NOTES:
Thanks for installing Rasa X 0.35.1 !

Check out the Rasa X docs here for more help:
https://rasa.com/docs/rasa-x/

I have added export KUBECONFIG=/etc/rancher/k3s/k3s.yaml in ~\.bashrc. When I cat the file, I get this:

$ cat $KUBECONFIG

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: ...
    server: https://127.0.0.1:6443
  name: default
contexts:
- context:
    cluster: default
    namespace: rasa
    user: default
  name: default
current-context: default
kind: Config
preferences: {}
users:
- name: default
  user:
    client-certificate-data: ...
    client-key-data: ...

Here it says it runs on port 6443, while the Action is trying to connect to port 8080. Is that the problem?

Sorry if those are dumb questions, but it’s my first time with Docker, Kubernetes, and Helm.

Your Kubernetes cluster has to be available via the Internet so that you can access it from a GH workflow. Additionally, you have to add a step in your workflow that will give you access to your cluster.

It looks like you use k3s on your local machine/server that’s is available only via localhost. It means that you won’t be able to reach your Kubernetes cluster from the GH workflow.

1 Like

Thanks for your reply.

I am working on a server that is not yet available on the Internet yet. I don’t know how I haven’t thought of that… What are those steps I should add in the workflow by then?

For now, is it the same if I manually enter the helm upgrade command on the server after running the GitHub Action? Or do I keep using docker build and docker push?

I am working on a server that is not yet available on the Internet yet. I don’t know how I haven’t thought of that… What are those steps I should add in the workflow by then?

It up to you how you wanna deal with it, e.g. you can use this action Kubernetes set context · Actions · GitHub Marketplace · GitHub

For now, is it the same if I manually enter the helm upgrade command on the server after running the GitHub Action? Or do I keep using docker build and docker push ?

The part responsible for building an image is ok, and you can leave it in your workflow, for now, it looks like you have to manually execute helm upgrade on your machine.

1 Like

You’ve been a huge help. Thank you so much.