39

I have this script createmap.sh in the public/scripts folder. I need to run it on master deployment the code in yaml file is

name: create-map
on: push

run: .public/script.sh
runs-on: ubuntu-latest
shell: bash

it is a simple script that is supposed to create a sitemap and ping google

# yarn sitemap
$ cd public
$ rm -rf sitemap
$ mkdir sitemap
$ cd ..
$ cd scripts
$ node ./sitemap-posts.js
$ node ./compress-map.js
$ node ./create-one-map.js

$ curl http://google.com/ping?sitemap=https://website.com/sitemap.xml

My folder structure is rootdirectory/scripts and rootdirectory/public

When I deploy the scripts are not run and I don't know where the problem is

1
  • Do you have any error on console? If yes, then include that in the post and also show us the contents of directories scripts and public with ls -l Commented Jan 7, 2021 at 9:49

2 Answers 2

63

You need to add permission for execution:

jobs:
  run_tests:
    runs-on: ubuntu-20.04
    steps:
    - uses: actions/checkout@v2
    - name: Run script file
      run: |
         chmod +x ./public/scripts/test.sh
         ./public/scripts/test.sh
      shell: bash
Sign up to request clarification or add additional context in comments.

8 Comments

It is up to you. There is no restriction here. You only need to pay attention to refer properly to them. Do it in a place where it is convenient for you.
I am a beginner in this. actually this is the only deployment in Actions I will be doing. Can you modify it a bit to include installing npm modules. I thought the packages in package.json file would be used
@KrzysztofMadej : What's the point in setting the x-bit before every execution? It should be sufficient to set it once manually. An alternative would be to use bash ./public/scripts/test.sh as run-command. In this case, the x-bit does not matter.
The point is to have file executable. There are various way of getting this. Your alternative also should work. However, just run: ./public/scripts/test.sh doesnt work.
|
7

You can avoid having to make it executable on every iteration if you update the index in git as follows:

git update-index --chmod=+x ./.github/script.sh

You can find a more detailed explanation @ https://git-scm.com/docs/git-update-index.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.