checkout: Permission denied when "Deleting the contents of"
Hi checkout team,
I’m having an issue when actions/checkout@v2 is trying to delete the repository:
I tried to change the permissions of the file but still happening, this has been happening since yesterday. I think that could be a bug but correct me if I’m wrong.
My .github/workflow/docker.yml
is like this:
name: MorciTravel CI
on: [push]
jobs:
morcitravel_job:
name: Morcitravel job
runs-on: ubuntu-latest
env:
KILL_JAVA_SH: ${{ github.workspace }}/ci/kill_java_process.sh
SERVER_PUB_KEY: ${{ github.workspace }}/data/server/server_pub_key.txt
JAVA_CMD_PATH: /opt/prod_jdk/bin/java
JAR_NAME: morci-travel-api-
services:
mongodb:
image: mongo:4-bionic
ports:
- 27017:27017
volumes:
- ${{ github.workspace }}/data/mongo/001_users.js:/docker-entrypoint-initdb.d/001_users.js
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Set up JDK 13
uses: actions/setup-java@v1
with:
java-version: 13
- name: Test & Package frontend
run: mvn -B clean install -pl :morci-travel-frontend
- name: Create version
run: |
APP_RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
APP_RELEASE_VERSION_ARRAY=(${APP_RELEASE_VERSION//./ })
((APP_RELEASE_VERSION_ARRAY[2]++))
APP_RELEASE_VERSION="${APP_RELEASE_VERSION_ARRAY[0]}.${APP_RELEASE_VERSION_ARRAY[1]}.${APP_RELEASE_VERSION_ARRAY[2]}"
echo "::set-env name=JAR_NAME::$JAR_NAME$APP_RELEASE_VERSION-SNAPSHOT.jar"
mvn -B --batch-mode release:update-versions -DdevelopmentVersion=$APP_RELEASE_VERSION-SNAPSHOT
- name: Test & Package backend
run: mvn -B clean test package -pl :morci-travel-api
- name: Prepare SSH Keys
run: |
mkdir -p ~/.ssh
echo "${{ secrets.KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
cat "$SERVER_PUB_KEY" > ~/.ssh/known_hosts
chmod 600 ~/.ssh/known_hosts
- name: Kill java process
run: |
ssh -p ${{ secrets.PORT }} ${{ secrets.USERNAME }}@${{ secrets.HOST }} 'bash -s' < $KILL_JAVA_SH
- name: Remove old artifacts
run: |
ssh -p ${{ secrets.PORT }} ${{ secrets.USERNAME }}@${{ secrets.HOST }} "rm -rf morci-travel-api-*.jar"
- name: Copy jar to server
run: |
scp -P ${{ secrets.PORT }} ${{ github.workspace }}/morci-travel-api/target/$JAR_NAME ${{ secrets.USERNAME }}@${{ secrets.HOST }}:~
- name: Launch app
run: |
ssh -f -p ${{ secrets.PORT }} ${{ secrets.USERNAME }}@${{ secrets.HOST }} "$JAVA_CMD_PATH -Xms64M -Xmx256M -jar $JAR_NAME &"
- name: Commit version
run: |
git config --global user.name 'Nicolas Vargas Ortega'
git config --global user.email 'soasada@users.noreply.github.com'
git commit -am "AUTOMATIC: Updated version"
git push
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 48
- Comments: 37 (3 by maintainers)
Commits related to this issue
- Use non-root user in actions Refs: https://github.com/actions/checkout/issues/211#issuecomment-680125896 — committed to felipecrs/dotfiles by felipecrs 4 years ago
- ci: chmod files before moving them See: https://github.com/actions/checkout/issues/211#issuecomment-611986243 [changelog skip] — committed to williamdes/mariadb-mysql-kbs by williamdes 4 years ago
- ci: chmod and chown docs before moving them See: https://github.com/actions/checkout/issues/211#issuecomment-611986243 [changelog skip] — committed to williamdes/mariadb-mysql-kbs by williamdes 4 years ago
- ci: sudo move the docs See: https://github.com/actions/checkout/issues/211#issuecomment-611986243 [changelog skip] — committed to williamdes/mariadb-mysql-kbs by williamdes 4 years ago
- ci(dashboard): fix media folder permissions error Since CI user does not have permissions then the file tests cannot occur. Refs: https://github.com/actions/checkout/issues/211#issuecomment-61198624... — committed to NobleAscent/AgrifoodIT by tuqman 3 years ago
- Fix CI for Weather enchancement (#12) * test(dashboard): Add postgresql support * ci(dashboard): setup postgresql as service * ci(dashboard): fix media folder permissions error Since CI user... — committed to NobleAscent/AgrifoodIT by tuqman 3 years ago
- change working dir to action user so files can be deleted Some data files from a previous run of this action are created with root as the owner. Because the action runs as a non-root user, such files... — committed to cmu-delphi/forecast-eval by nmdefries 3 years ago
- Try workaround of specifying "--user 1001" in check-rellinks. https://github.com/actions/checkout/issues/211#issuecomment-680107607 — committed to elves/elvish by xiaq 3 years ago
- ci: drop useless chown call AFAIK we anyway run self-hosted runners from root due to all those problems like [1]. No reason to include the hack into every workflow file. If we'll going to start runne... — committed to tarantool/tarantool by Totktonada 3 years ago
- ci: drop useless chown call AFAIK we anyway run self-hosted runners from root due to all those problems like [1]. No reason to include the hack into every workflow file. If we'll going to start runne... — committed to tarantool/tarantool by Totktonada 3 years ago
- ci: drop useless chown call AFAIK we anyway run self-hosted runners from root due to all those problems like [1]. No reason to include the hack into every workflow file. If we'll going to start runne... — committed to tarantool/tarantool by Totktonada 3 years ago
- ci: drop useless chown call AFAIK we anyway run self-hosted runners from root due to all those problems like [1]. No reason to include the hack into every workflow file. If we'll going to start runne... — committed to tarantool/tarantool by Totktonada 3 years ago
- ci: drop useless chown call AFAIK we anyway run self-hosted runners from root due to all those problems like [1]. No reason to include the hack into every workflow file. If we'll going to start runne... — committed to tarantool/tarantool by Totktonada 3 years ago
- Try workaround https://github.com/actions/checkout/issues/211\#issuecomment-611986243 — committed to jdelnano/workflow-cps-global-lib-http-plugin by jdelnano 2 years ago
- Workaround for https://github.com/actions/checkout/issues/211 — committed to whikloj/stomp-php by whikloj a year ago
- Patch: add a `chown` step to take ownership According to actions/checkout#211 — committed to HuangFuSL/HuangFuSL.github.io by HuangFuSL 10 months ago
- Fix: deployment fail (#191) * Fix: override `WORKDIR` command * Patch: disabled if condition for testing * Patch: disable preceding workflow * Patch: add verbose option to check path * Pa... — committed to HuangFuSL/HuangFuSL.github.io by HuangFuSL 10 months ago
- github: checkout in a different directory than workspace Because we are now mounting volumes, the current user may not have the rights to delete the repository. Clone it elsewhere to workaround that ... — committed to akvorado/akvorado by vincentbernat 3 months ago
I experienced the same issue. To get around this I ran a command to change file permissions right before executing actions/checkout:
@felipecrs Something like this (runs-on must be equal):
But it is ridiculous.
This worked for me - but I used
${{ github.workspace }}
as the pathI was able to resolve this by adding this step:
Only solution that worked for me after 12 hours of debugging.
Here is another solution that is a bit hacky but works to clean up the working directory before attempting any checkout:
Hope it helps!
You may need to specify the checkout
path
input to avoid the volume mount being under the repository.The containers are setup at the beginning of the job. And git clone will fail if the directory isnt empty.
You could always symlink the dir back in place (or copy the files), if you need the data underneath the repository. Or if it’s your test data, consider updating your scripts to allow the location to be overridden using an env var.
@Yalchin403
AutoModality/action-clean@v1
action fixed this for meI had to add “echo password” before, otherwise sudo is asking for password.
echo ${{secrets.DEPLOY_PASSWORD}} | sudo -S chown -R $USER:$USER /home/github/deployment/{REPOSITORY_NAME_HERE}
Is there a better solution?
I’m going to add a troubleshooting doc. I’ll add a section for this.
Is there any way to simply make the checkout work with containers running as non-root?
I’m trying something like:
and it does not work.
If I run the container as root it works by the way.
Since I could not find an issue that exactly describes the real root cause and how to solve it, I created one. I believe this can now be closed.
I believe the maintainers should close this issue since it’s not caused by this Action. And of course, point to the relevant repository.
Reading https://github.com/actions/runner/issues/434 description, I don’t think it’s so related.
Any plan on fix this, this is quite annoying since many services limit user not to be root.
@felipecrs Well, how it looks, GitHub runner, is running under user, with UID: 1001 and GID: 116 So, change it to:
I was not able to solve this, and instead had to stop using a container altogether. Would love a solution if anyone has one. FYI @JungHanter @ekahannes