Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Curl command in Github action fails on "no such file or directory"

I am running my Github Action on a self-hosted machine. The action should send a curl command:

name: Build and Publish

on:
  push:
    branches:
      - master

jobs:
  trigger:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v2
      - name: curl command
        working-directory: /home/ubuntu/actions-runner/_work/${{ github.repository }}
        run: |
          DATA= '{"data": { "repository" : "${{ github.repository }}", "package_version" : "0.1.0-${{ github.sha }}", "branch" : "${{ github.sha }}" }}'
          printf -v content "$DATA"
          curl --request 'POST' --data "$content" 'http://<my-url>/actions'

The output seems strange as it is looking for a certain path with an .sh script and fails on "no such file or directory"

    Run DATA= '{"data": { "repository" : "iz/<my-repo>", "package_version" : "0.1.0-41b1005d15069bbb515b52416721b84", "branch" : "41b1005d15069bbb515b52416721b84" }}'
  DATA= '{"data": { "repository" : "iz/<my-repo>", "package_version" : "0.1.0-41b1005d15069bbb515b52416721b84", "branch" : "41b1005d15069bbb515b52416721b84" }}'
  printf -v content "$DATA"
  curl --request 'POST' --data "$content" 'http://<my-url>/actions'
 
shell: /usr/bin/bash -e {0}
/home/ubuntu/actions-runner/_work/_temp/5fee3c-a409-4db-48f-cb1d16d15d.sh: line 1: {"data": { "repository" : "iz/<my-repo>", "package_version" : "0.1.0-41b1005d15069bbb515b52416721b84", "branch" : "41b1005d15069bbb515b52416721b84" }}:
No such file or directory
Error: Process completed with exit code 127.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try removing the space after DATA=. It thinks you are temporarily setting DATA to empty for executing the command '{"data": { "repository" :… instead of setting DATA to that value permanently (i.e. non-temporarily).

Set X to Y (until overwritten):

X=Y

Set X to Y temporarily during execution of CMD:

X=Y CMD
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading