Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run a bash script located in public folder github actions

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

like image 967
Taio Avatar asked Jan 07 '21 09:01

Taio


People also ask

How do I run a bash script in GitHub actions?

Run the bash script from an action using run: bash ${GITHUB_WORKSPACE}/scripts/example.sh my-folder-name and use $1 to use the argument you passed. This makes it easy to re-use a script from multiple actions.

How do I run a bash script in terminal?

Using bash or sh You must have git bash installed if you are using Windows. For Linux and macOS, bash is installed by default. In this method, we type bash followed by the file name with extension i.e. sh in this case. In a terminal, run the following code by replacing the filename with your bash script filename.

Can you CD in GitHub actions?

With GitHub Actions, you can trigger CI/CD workflows and pipelines of webhooks from these apps (even something simple, like a chat app message, if you've integrated your chat app into your GitHub repository, of course).


1 Answers

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
like image 181
Krzysztof Madej Avatar answered Oct 23 '22 09:10

Krzysztof Madej