Due to bandwidth limits, I'm trying to checkout a subfolder of my project to Github Actions and found this Action: https://github.com/marketplace/actions/checkout-files
New (broken) Script:
name: Create Build Target
run-name: ${{ github.actor }} is creating ${{ github.ref_name }}
on: create
jobs:
Create:
runs-on: ubuntu-latest
steps:
- name: Checkout to access bash script
uses: Bhacaz/checkout-files@v2
with:
files: CICD
- name: Create Buildtarget info on Unity Cloud Build
env:
api_key: ${{ secrets.api_key }}
org_id: ${{ secrets.org_id }}
project_id: ${{ secrets.project_id }}
branch_name: ${{ github.ref_name }}
credential_id: ${{ secrets.credential_id }}
run: CICD/CreateBuildTarget.sh
I get an error in the Github Actions terminal when triggering the above .yaml file to check out a subdirectory instead of the whole project:
/home/runner/work/_temp/2ddc6165-7186-415a-8d87-bc4d746f659f.sh: line 1: CICD/CreateBuildTarget.sh: Permission denied
60
Error: Process completed with exit code 126.
I had this working before, and made sure the files had the correct permissions:
myUserName@myUserNames-MacBook-Pro cicd % ls -l
total 16
-rwxr-xr-x@ 1 myUserName staff 2239 Feb 3 11:17 CreateBuildTarget.sh
-rwxr-xr-x@ 1 myUserName staff 449 Feb 3 11:18 DeleteBuildTarget.sh
The only thing I changed was the checkout action.
Before (working):
- name: Checkout to access bash script
uses: actions/[email protected]
After (not working):
- name: Checkout to access bash script
uses: Bhacaz/checkout-files@v2
with:
files: CICD
Is what I'm trying to do even possible? For now, I changed the script to trigger on pull request open/reopen, instead of create, but I still want to only check out a subdirectory instead of the whole project.
CodePudding user response:
While your files are executable locally (on your machine), they might not have been added to your Git repository with x
(the executable bit).
Which means, once the GitHub Action checks out your file (even limiting itself to one subfolder), said sh
script files are not executable.
Try locally to do, using git add --chmod= x
:
cd /path/to/repository
cd CICD
git add --chmod= x *.sh
git commit -m "Add executable bit in CICD folder"
git push
Then check if your GitHub Action has the same issue.
CodePudding user response:
The action you're using isn't setting the execute bits on the .sh files. It's relatively simple to add them manually after restoring the files, but you might want to fork the action and make it do the right thing.
Try using a Sparse Checkout action instead, it would rely on Git to restore the files and has a lot more expected default behaviors built-in:
gogaille/sparse-checkout