docs icon indicating copy to clipboard operation
docs copied to clipboard

Document that `github.action_repository` and `github.action_ref` are not promised for composite actions

Open jsoref opened this issue 1 year ago • 2 comments

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/actions/learn-github-actions/contexts#github-context

What part(s) of the article would you like to see updated?

| github.action_ref | string | For a step executing an action, this is the ref of the action being executed. For example, v2. | | github.action_repository | string | For a step executing an action, this is the owner and repository name of the action. For example, actions/checkout. |

Need to specify that they are not promised to work for composite actions.

(This is bizarre, but this is the information I received from GitHub support)

Additional information

https://support.github.com/ticket/personal/0/2042233#tc-15297292650900

jsoref avatar May 01 '23 22:05 jsoref

👋 @jsoref - Thanks for opening an issue! And thanks for linking us to the support ticket.

I'll get this triaged for review! :zap:

cmwilson21 avatar May 02 '23 14:05 cmwilson21

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/actions/learn-github-actions/contexts#github-context

What part(s) of the article would you like to see updated?

| github.action_ref | string | For a step executing an action, this is the ref of the action being executed. For example, v2. |

| github.action_repository | string | For a step executing an action, this is the owner and repository name of the action. For example, actions/checkout. |

Need to specify that they are not promised to work for composite actions.

(This is bizarre, but this is the information I received from GitHub support)

Additional information

https://support.github.com/ticket/personal/0/2042233#tc-15297292650900

petergau avatar May 03 '23 03:05 petergau

@cmwilson21 ?

jsoref avatar Jul 10 '23 16:07 jsoref

@jsoref sorry about that! Slipped through during the US holiday last week. 💛

cmwilson21 avatar Jul 11 '23 20:07 cmwilson21

@cmwilson21 ...

jsoref avatar Sep 18 '23 16:09 jsoref

Thanks for hanging in there with us while we're working through the backlog of issues @jsoref. I took a look through this and agree that this would be a good addition to the docs.

What do you think about adding the following sentence to each of the github.action_ref and github.action_repository descriptions?

This context does not work for composite actions. For more information, see "Creating a composite action."

jc-clark avatar Sep 26 '23 20:09 jc-clark

Since ~1/5 of all issues in the backlog are mine, I'm ok w/ that. I'm also fairly tolerant of delays (much less of annoying bots that attack my tickets).

I really should have left a better breadcrumbs for this problem. I'm pretty sure I worked around it, but I clearly didn't document how.

Our engineering team determined that the github.action_repository and github.actions_ref [sic] context values are only intended to work with non-composite actions.

For now, reverting to using these contexts only from the env key within the composite action will achieve the expected values. Alternatively, you can leverage inputs with your custom action to ensure the value is consistent if needed in a run command.

It looks like the workaround is to do:

  run: echo "$action_ref"
  env:
    action_ref: ${{ github.action_ref }}

instead of:

  run: echo "${{ github.action_ref }}"

As the creating page doesn't mention env / run and doesn't encourage using the former (it probably should), I don't know that the link is helpful right now...

jsoref avatar Sep 26 '23 20:09 jsoref

Good

Shahid2687 avatar Sep 26 '23 21:09 Shahid2687

Ah I see what you're saying here, and really appreciate the extra breadcrumbs. What do you think about adding this revision for the github.action_ref and github.action_repository descriptions?

To make this context work with composite actions, reference it within the env context of the composite action.

I might be missing the mark here, so let me know if alternate wording would make more sense!

jc-clark avatar Sep 26 '23 22:09 jc-clark

That might work. It might be worth it to be more explicit and mention "and not run".

It might even be useful to generally suggest not using it in run. In general, it's a bad idea/practice to expand things into run.

If I were you, I'd talk with engineering a bit more about the wording. Sorry.

jsoref avatar Sep 27 '23 13:09 jsoref

No problem, @jsoref. Thank you for the pointers. This gives me a really good starting point.

I'll go ahead open up an internal issue to make these improvements and close this one out. I'll be able to coordinate with the engineers from there.

jc-clark avatar Sep 27 '23 17:09 jc-clark