docksal / ci-agent

CI agent Docker image for Docksal Sandboxes
MIT License
9 stars 16 forks source link

Github Action workflow: bad function name #88

Closed DanielLopez-nbcuni closed 7 months ago

DanielLopez-nbcuni commented 1 year ago

When using docksal/ci-agent:latest OR docksal/ci-agent:edge-php and using the github workflow example.

name: Docksal sandbox

on:
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: docksal/ci-agent:edge-php
    env:
      CI_SSH_KEY: ${{ secrets.CI_SSH_KEY }}
      DOCKSAL_HOST_IP: ${{ secrets.DOCKSAL_HOST_IP }}
      DOCKSAL_HOST_SSH_KEY: ${{ secrets.DOCKSAL_HOST_SSH_KEY }}
      GITHUB_TOKEN: ${{ github.token }}
      REMOTE_CODEBASE_METHOD: git
    steps:
      - name: Build sandbox
        run: |
          source build-env
          sandbox-init

Got the following error; /__w/_temp/088f377d-c351-4fb2-a72b-53e3f1b60aa4.sh: /usr/local/bin/build-env: line 32: syntax error: bad function name Error: Process completed with exit code 2.

DanielLopez-nbcuni commented 1 year ago

I noticed that the echo-debug function has a hyphen in the name and the action is running in sh as can be seen from this screenshot. Could it be a problem with the hyphen in the name? https://unix.stackexchange.com/questions/168221/are-there-problems-with-hyphens-in-functions-aliases-and-executables

image image

DanielLopez-nbcuni commented 1 year ago

After rebuilding the image with echo_debug instead of echo-debug. That fixed the error.

However, It then failed again at line 43 due to the <<< and it being sh shell. So the next fix was running the github action step with the shell parameter set to bash.

 - name: Build sandbox
        shell: bash
        run: |
          source build-env
          sandbox-init