rossjrw / pr-preview-action

GitHub Action that deploys a pull request preview to GitHub Pages, similar to Vercel and Netlify, and cleans up after itself.
https://github.com/marketplace/actions/deploy-pr-preview
MIT License
275 stars 44 forks source link

`uses:` keyword is not currently supported #33

Open james-s-w-clark opened 1 year ago

james-s-w-clark commented 1 year ago

I have googled around the error uses: keyword is not currently supported, but couldn't figure out how to fix this issue (other actions are working fine, and they use uses). It's the first time I've seen this, so I thought I'd raise an issue here.

I can see that the Action works nice for public repos:

https://github.com/rossjrw/pr-preview-action/tree/gh-pages/pr-preview/pr-8 https://github.com/rossjrw/pr-preview-action/pull/8

I'm trying this in GitHub Enterprise on a self-hosted runner, but it fails with a really weird error.

Action run logs

2023-02-14T18:56:00.7683072Z Found online and idle self-hosted runner(s) in the current repository's organization/enterprise account that matches the required labels: 'self-hosted'
2023-02-14T18:56:00.7683941Z Waiting for a self-hosted runner to pick up this job...
2023-02-14T18:56:10.0154451Z Current runner version: '2.302.0'
2023-02-14T18:56:10.0162322Z Runner name: 'my-runner'
2023-02-14T18:56:10.0162762Z Runner group name: 'Default'
2023-02-14T18:56:10.0163385Z Machine name: 'abc123def'
2023-02-14T18:56:10.0165051Z ##[group]GITHUB_TOKEN Permissions
2023-02-14T18:56:10.0165679Z Actions: write
2023-02-14T18:56:10.0165898Z Checks: write
2023-02-14T18:56:10.0166176Z Contents: write
2023-02-14T18:56:10.0166437Z Deployments: write
2023-02-14T18:56:10.0166676Z Discussions: write
2023-02-14T18:56:10.0166887Z Issues: write
2023-02-14T18:56:10.0167107Z Metadata: read
2023-02-14T18:56:10.0167320Z Packages: write
2023-02-14T18:56:10.0167539Z PullRequests: write
2023-02-14T18:56:10.0167798Z RepositoryProjects: write
2023-02-14T18:56:10.0168015Z SecurityEvents: write
2023-02-14T18:56:10.0168300Z Statuses: write
2023-02-14T18:56:10.0168521Z ##[endgroup]
2023-02-14T18:56:10.0172360Z Prepare workflow directory
2023-02-14T18:56:10.1738386Z Prepare all required actions
2023-02-14T18:56:10.2070688Z Getting action download info
2023-02-14T18:56:16.5313348Z Download action repository 'actions/checkout@v3' (SHA:ac593985615ec2ede58e132d2e21d2b1cbd6127c)
2023-02-14T18:56:16.8288999Z Download action repository 'rossjrw/pr-preview-action@v1' (SHA:eac2838daf487e8f054a4bc10dc957431cd6270b)
2023-02-14T18:56:17.2948704Z ##[error]`uses:` keyword is not currently supported.

Workflow yaml

Indentaiton may be off due to copy paste, but here is the action - pretty much the same as an example from the readme:

name: Deploy PR previews
concurrency: preview-${{ github.ref }}
 
on:
  pull_request:
    types:
    - opened
    - reopened
    - synchronize
    - closed
jobs:
  deploy-preview:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v3
      - run: yarn install && yarn build
      - uses: rossjrw/pr-preview-action@v1

If I remove - uses: rossjrw/pr-preview-action@v1, the logs manage to checkout and then try and install yarn etc. So, it seems like it gets confused on the very last line.

rossjrw commented 1 year ago

That's... really odd. I'm sorry, I've never seen this happen before.

I wonder if it's to do with how the action is set up. actions/checkout runs entirely out of a JS script:

https://github.com/actions/checkout/blob/ac593985615ec2ede58e132d2e21d2b1cbd6127c/action.yml#L77-L80

But pr-preview-action it itself composed of sub-actions:

https://github.com/rossjrw/pr-preview-action/blob/9dac5c4777c535516ebf819f93aeadac70f66488/action.yml#L99-L102

I'm seeing some discussion in a PR on actions/runner about this - there's a very familiar error log at the bottom: https://github.com/actions/runner/pull/612

If I had to guess, I'd guess that the official GitHub runners have some flag set on them that is allowing them to run nested composite actions, but your self-hosted runner doesn't. I'm genuinely unsure what can be done about that, sorry.

Other than filing a bug report with actions/runner, the only advice I can give you is to consider another solution. If you need to stick with cloud services, perhaps Vercel/Netlify? Or alternatively you could copy and amend the procedure from this action (https://github.com/rossjrw/pr-preview-action/blob/main/action.yml) and retrofit it directly into your workflow. I can't guarantee you won't hit the same error somewhere else, but it might help.

james-s-w-clark commented 1 year ago

Hey Ross,

Good find with that link. This morning it clicked that you have some nested actions (I saw them at https://github.com/rossjrw/pr-preview-action#acknowledgements), and that I saw some stuff about composite. I tried tacking on some composite stuff to our Action, but I think that was the wrong place for it anyway.

I've just seen your's is marked with composite, in the last link you sent: https://github.com/rossjrw/pr-preview-action/blob/main/action.yml#L53.

I will try your suggestion of fitting the steps directly into our action, to remove a layer of nesting . If that fails, I'll dig more into self-hosted runners supporting composite actions.

Fantastic project btw :)

james-s-w-clark commented 1 year ago

The issue isn't with this action specifically, but seemingly with composite actions in self-hosted runners in general.

james-s-w-clark commented 1 year ago

@rossjrw

It's working great with the .yaml and /lib/*.sh files in-lined into our repo!

GitHub pages seems a bit picky with the deploy, but I'm trying some suggestions at https://github.com/JamesIves/github-pages-deploy-action/issues/48.


Tips for self-hosted users of this app:

rossjrw commented 1 year ago

Good to know that you've managed to get it mostly working @IdiosApps.

Sorry, I'm not sure what the linked issue has to do with self-hosted runners - could you clarify?

Is the section starting 'tips for self hosted users' something you recommend I add to my documentation?

james-s-w-clark commented 1 year ago

I guess the linked issue may not have anything to do with it - I hit some issues with it in this process though, so they seem relevant.

In-lining everything into our repo so it isn't composite was the main advice, and it only took a few hours to iterate and get it working from there.

I think the tips may save GitHub Enterprise users a little time, so adding them to the docs may be worthwhile. But, at least there is some searchable documentation here in this Issue that those users might find by Googling errors - so I'm happy either way :)

rossjrw commented 1 year ago

Reopening this issue as a documentation task

james-s-w-clark commented 1 year ago

Reopening this issue as a documentation task

In that case, I'm happy to raise a PR for it when I get some time :)