Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment fails if files are not writable or owned by root #58

Closed
opeik opened this issue Aug 27, 2022 · 8 comments
Closed

Deployment fails if files are not writable or owned by root #58

opeik opened this issue Aug 27, 2022 · 8 comments

Comments

@opeik
Copy link

opeik commented Aug 27, 2022

Hi there,

I tried to deploy my site which is built with NIx and actions/deploy-pages would fail with a cryptic error message.

name: Continuous deployment

on:
  push:
    branches: [main]
  
permissions:
  contents: read
  pages: write
  id-token: write

concurrency:
  group: cd
  cancel-in-progress: true

jobs:
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}

    runs-on: ubuntu-latest

    steps:
      - name: Checkout repo
        uses: actions/checkout@v3

      - name: Install Nix
        uses: cachix/install-nix-action@v15
        with:
          extra_nix_config: access-tokens = github.com=${{ github.token }}

      - name: Build website
        run: nix build --print-build-logs

      - name: Setup GitHub Pages
        uses: actions/configure-pages@v1

      - name: Upload website
        uses: actions/upload-pages-artifact@v1
        with:
          path: public

      - name: Deploy website
        id: deployment
        uses: actions/deploy-pages@v1

Which outputs this:

Actor: danth
Action ID: 2761250916
Artifact URL: https://pipelines.actions.githubusercontent.com/TbYKgfAZOYa7gipiGxQgSbih1nRuFlBDNpZeQ6z2I00IpqUyZA/_apis/pipelines/workflows/2761250916/artifacts?api-version=6.0-preview
{"count":1,"value":[{"containerId":1480084,"size":61440,"signedContent":null,"fileContainerResourceUrl":"https://pipelines.actions.githubusercontent.com/TbYKgfAZOYa7gipiGxQgSbih1nRuFlBDNpZeQ6z2I00IpqUyZA/_apis/resources/Containers/1480084","type":"actions_storage","name":"github-pages","url":"https://pipelines.actions.githubusercontent.com/TbYKgfAZOYa7gipiGxQgSbih1nRuFlBDNpZeQ6z2I00IpqUyZA/_apis/pipelines/1/runs/14/artifacts?artifactName=github-pages","expiresOn":"2022-07-30T14:44:47.4503161Z","items":null}]}
Creating deployment with payload:
{
	"artifact_url": "https://pipelines.actions.githubusercontent.com/TbYKgfAZOYa7gipiGxQgSbih1nRuFlBDNpZeQ6z2I00IpqUyZA/_apis/pipelines/1/runs/14/artifacts?artifactName=github-pages&%24expand=SignedContent",
	"pages_build_version": "5d3a8f8ecf3635514f0046294ddc600728eb75c4",
	"oidc_token": "***"
}
Created deployment for 5d3a8f8ecf3635514f0046294ddc600728eb75c4
{"page_url":"https://danth.github.io/coricamu/","status_url":"https://api.github.com/repos/danth/coricamu/pages/deployment/status/5d3a8f8ecf3635514f0046294ddc600728eb75c4","preview_url":""}

Error: Deployment failed, try again later.

From my testing actions/deploy-pages fails if the files are either not writable or owned by root. The output of a Nix build is both not writable and owned by root. I worked around this by clearing the permissions after building:

cp --recursive --dereference --no-preserve=mode,ownership result public

I don't think this should fail, since I expect the file permissions be cleared on deployment. Even so, the error message should at least be more clear.

@opeik opeik changed the title Deployment fails if files not writable or owned by root Deployment fails if files are not writable or owned by root Aug 27, 2022
myme pushed a commit to myme/myme.no that referenced this issue Oct 10, 2022
@JamesMGreene
Copy link
Contributor

JamesMGreene commented Nov 17, 2022

ℹ️ While it's not a complete fix, as this should indeed be handled on the server-side eventually, we have added a partial fix to the actions/upload-pages-artifact Action that should clear out such permissions: actions/upload-pages-artifact#34

Since you are using that Action with @v1 already, your future workflow runs will hopefully be successful without your cp ... workaround.

Please let us know if you're still running into issues.

@Gerschtli
Copy link

Gerschtli commented Nov 18, 2022

The permission problem itself might be resolved but in the example of OP, the directory for deployment is a symlink itself where the contents of ./result is not writeable. Judged by the warnings that should have been printed, your fix does not work for these cases, see https://github.com/Gerschtli/nix-formatter-pack/actions/runs/3499580588/jobs/5861357357.

Probably because chmod is running in . instead of inputs.path. But because chmod is not derefencing symlinks that may exist in inputs.path, you should probably run the cp --recursive --dereference before doing chmod.

@cor
Copy link

cor commented Nov 18, 2022

@sempruijs looks like this is the issue you've been encountering

@yoannchaudet
Copy link
Collaborator

We made changes recently around that which should help. Closing.

@gilice
Copy link

gilice commented Dec 29, 2022

@yoannchaudet are those changes merged/released yet? I ran into the same issue, with nix, too.

@yoannchaudet
Copy link
Collaborator

The permissions fix is included in https://github.com/actions/upload-pages-artifact/releases/tag/v1.0.6.

It's best effort and we don't change ownership on the files. If that's your issue, I am afraid you will need to handle that yourself with an extra chown command.

@Gerschtli
Copy link

Why is it not possible to take care of necessary ownership requirements with this action? I am glad to help out.

@pinpox
Copy link

pinpox commented Jan 10, 2023

Running into this aswell. Is the chown still the way to use this?

gjz010 added a commit to isQ-Team/isQ-Compiler that referenced this issue Jan 28, 2023
pyrotelekinetic added a commit to pyrotelekinetic/pyrotelekinetic.github.io that referenced this issue Feb 8, 2023
yjt98765 pushed a commit to isQ-Team/isQ-Compiler that referenced this issue Apr 25, 2023
gjz010 added a commit to isQ-Team/isQ-Compiler that referenced this issue Jun 13, 2023
MostAwesomeDude added a commit to MostAwesomeDude/brismu that referenced this issue Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants