trstringer / manual-approval

Pause your GitHub Actions workflow and request manual approval from set approvers before continuing
MIT License
331 stars 83 forks source link

How to set url for enterprise github? #75

Open juliusoh opened 1 year ago

juliusoh commented 1 year ago

My github org repo is like github.company.net/repo/

but this action is rendering the url like github.com/repo/

patrick-lerch commented 1 year ago

+1

augustomelo commented 1 year ago

I think you might need to configure the following env variables GITHUB_SERVER_URL and GITHUB_API_URL https://github.com/trstringer/manual-approval/blob/a824dad59ac64ac825ab8725599e483e24aa2815/main.go#L106

I think with that configuration it will create on the right place, but still the message will be wrong because of this line: https://github.com/trstringer/manual-approval/blob/a824dad59ac64ac825ab8725599e483e24aa2815/approval.go#L47

juliusoh commented 1 year ago

I changed the env variables but still same

augustomelo commented 1 year ago

The latest version v1.9.0 doesn't contain the changes that fix that, did you tried to point it to main ? Also , could you share some logs from the action ?

aserrallerios commented 7 months ago

It doesn't seem to work for me:

env:
  GITHUB_SERVER_URL: ${{github.server_url}}
      - uses: trstringer/manual-approval@dd1555b1d17966cb58500676d79a181c53bb6c12

And I still get the URL from github.com.

augustomelo commented 7 months ago

Hello @aserrallerios

From the GH Actions docs

The default environment variables that GitHub sets are available to every step in a workflow.

Because default environment variables are set by GitHub and not defined in a workflow, they are not accessible through the env context

It is not possible to override a default environment variable (source item #2), it depends where your runners are running and how you configured the environment variables on the runner. For example if I run this action using act, and pass those values on .env file: GITHUB_SERVER_URL=www.not-github.com GITHUB_API_URL=api.not-github.com that will do the trick.

The fix that was done on #90 was to format the message with the value of the GITHUB_SERVER_URL and not have it as a static string (https://github.com/%s) nor as customized value

aserrallerios commented 6 months ago

Hey @augustomelo sorry for the delay.

I'm not sure I understand your message, so I removed the explicit GITHUB_SERVER_URL update and validated that my runners were using the right value for the variable.

Run echo $GITHUB_SERVER_URL
https://github.some-domain.com/

But it turns out that the approval still has the github.com domain.

Workflow is pending manual review.
URL: https://github.com/xxxxxx

So I might be missing something super obvious here. Maybe my runners are not injecting the right env variables when running actions?

augustomelo commented 6 months ago

Hello @aserrallerios, no worries 😄

Looking at the code it creates the github client by using the values that are set on $GITHUB_SERVER_URL and $GITHUB_API_URL ((code)[https://github.com/trstringer/manual-approval/blob/dd1555b1d17966cb58500676d79a181c53bb6c12/main.go#L106-L107]) and from the docs those values cannot be override by the actions, so I am not sure what is happening on your end.

Also it is important to notice that I am currently not using this action, so it can be that my fix didn't fix anything at all.

aserrallerios commented 6 months ago

Weird, I'm going to ask the our platform team. May I ask if you're using an alternative action to this one?

augustomelo commented 6 months ago

No I am not using an alternative action