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

feature request: ability to configure the github domain of the default git context (for Github Enterprise users) #326

Closed
digitalkram opened this issue Mar 31, 2021 · 7 comments · Fixed by #328
Labels
kind/enhancement New feature or request

Comments

@digitalkram
Copy link

The domain of the default context is hard-coded to github.com:

_defaultContext = `https://github.com/${github.context.repo.owner}/${

For users of Github Enterprise running on a custom domain like git.mycompany.com it would be great if this would be configurable like:

[...]
      -
        name: Build and push
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          push: false
          tags: user/app:latest
          ghdomain: git.mycompany.com
[...]
@crazy-max
Copy link
Member

@digitalkram

For users of Github Enterprise running on a custom domain like git.mycompany.com it would be great if this would be configurable like:

I think we could instead extract this from the runner context. Can you add this step in your workflow and tell me if your domain is found in the context? Thanks.

@crazy-max
Copy link
Member

crazy-max commented Mar 31, 2021

@digitalkram

From what I see, GITHUB_SERVER_URL env var should be good or github.server_url.

@digitalkram
Copy link
Author

@crazy-max Thanks a ton for your fast and promising replies.
It did set the env var GITHUB_SERVER_URL on all possible levels (namely: runner process calling env (systemd unit), workflow level, job level and step level - that's because it did not help and I thought it is not taken into account - which was wrong).

Those values are actually set - verified with your dump-context action (redacted a bit - need to be careful here):

Dump Env vars
CI=true
GITHUB_ACTION=crazy-maxghaction-dump-context
GITHUB_ACTIONS=true
GITHUB_ACTION_PATH=/opt/actions-runner/_work/_actions/crazy-max/ghaction-dump-context/v1
GITHUB_ACTOR=<gituser>
GITHUB_API_URL=https://git.mycompany.com/api/v3
GITHUB_BASE_REF=
GITHUB_ENV=/opt/actions-runner/_work/_temp/_runner_file_commands/set_env_08b9ca60-384a-4389-a599-8d9f7fd064ff
GITHUB_EVENT_NAME=workflow_dispatch
GITHUB_EVENT_PATH=/opt/actions-runner/_work/_temp/_github_workflow/event.json
GITHUB_GRAPHQL_URL=https://git.mycompany.com/api/graphql
GITHUB_HEAD_REF=
GITHUB_JOB=docker
GITHUB_PATH=/opt/actions-runner/_work/_temp/_runner_file_commands/add_path_08b9ca60-384a-4389-a599-8d9f7fd064ff
GITHUB_REF=refs/heads/master
GITHUB_REPOSITORY=<gitorg>/<gitrepo>
GITHUB_REPOSITORY_OWNER=<gitorg>
GITHUB_RETENTION_DAYS=90
GITHUB_RUN_ID=1194
GITHUB_RUN_NUMBER=15
GITHUB_SERVER_URL=https://git.mycompany.com
GITHUB_SHA=d4ec8bcc430551b4f239c0c5b748d1c9b9020110
GITHUB_WORKFLOW=imagebuild
GITHUB_WORKSPACE=/opt/actions-runner/_work/<gitrepo>/<gitrepo>
HOME=/home/<gitorg>app
HTTPS_PROXY=http://localhost:3128/
HTTP_PROXY=http://localhost:3128/
LANG=en_US
LANGUAGE=en_US:
LC_ADDRESS=C.UTF-8
LC_ALL=C.UTF-8
LC_IDENTIFICATION=C.UTF-8
LC_MEASUREMENT=C.UTF-8
LC_MONETARY=C.UTF-8
LC_NAME=C.UTF-8
LC_NUMERIC=C.UTF-8
LC_PAPER=C.UTF-8
LC_TELEPHONE=C.UTF-8
LC_TIME=C.UTF-8
LESSCLOSE=/usr/bin/lesspipe %s %s
LESSOPEN=| /usr/bin/lesspipe %s
LOGNAME=<gitorg>app
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
MAIL=/var/mail/<gitorg>app
OLDPWD=/root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PWD=/opt/actions-runner/_work/<gitrepo>/<gitrepo>
RUNNER_OS=Linux
RUNNER_TEMP=/opt/actions-runner/_work/_temp
RUNNER_TOOL_CACHE=/opt/actions-runner/_work/_tool
RUNNER_TRACKING_ID=github_292ba0d7-49bb-4d25-9fee-435590eb48ce
RUNNER_WORKSPACE=/opt/actions-runner/_work/<gitrepo>
SHELL=/usr/sbin/nologin
SHLVL=3
SUDO_COMMAND=/bin/bash
SUDO_GID=0
SUDO_UID=0
SUDO_USER=root
TERM=xterm-256color
USER=<gitorg>app
USERNAME=<gitorg>app
_=/usr/bin/env
http_proxy=http://localhost:3128/
https_proxy=http://localhost:3128/

Dump runner context
{
  "os": "Linux",
  "tool_cache": "/opt/actions-runner/_work/_tool",
  "temp": "/opt/actions-runner/_work/_temp",
  "workspace": "/opt/actions-runner/_work/<gitrepo>"
}

Dump GitHub context
{
  "token": "***",
  "job": "docker",
  "ref": "refs/heads/master",
  "sha": "d4ec8bcc430551b4f239c0c5b748d1c9b9020110",
  "repository": "<gitorg>/<gitrepo>",
  "repository_owner": "<gitorg>",
  "repositoryUrl": "git://git.mycompany.com/<gitorg>/<gitrepo>.git",
  "run_id": "1194",
  "run_number": "15",
  "retention_days": "90",
  "actor": "<gituser>",
  "workflow": "imagebuild",
  "head_ref": "",
  "base_ref": "",
  "event_name": "workflow_dispatch",
  "event": {
    "enterprise": {
      "avatar_url": "https://avatars.git.mycompany.com/b/1?",
      "created_at": "2018-12-03T11:09:12Z",
      "description": "The XYZ Group",
      "html_url": "https://git.mycompany.com/enterprises/xyz",
      "id": 1,
      "name": "XYZ AG",
      "node_id": "MDEwOkVudGVycHJpc2Ux",
      "slug": "xyz",
      "updated_at": "2021-03-20T05:56:38Z",
      "website_url": "https://www.xyz.com"
    },
    "inputs": null,
    "organization": {
      "avatar_url": "https://avatars.git.mycompany.com/u/2156?",
      "description": "",
      "events_url": "https://git.mycompany.com/api/v3/orgs/<gitorg>/events",
      "hooks_url": "https://git.mycompany.com/api/v3/orgs/<gitorg>/hooks",
      "id": 2156,
      "issues_url": "https://git.mycompany.com/api/v3/orgs/<gitorg>/issues",
      "login": "<gitorg>",
      "members_url": "https://git.mycompany.com/api/v3/orgs/<gitorg>/members{/member}",
      "node_id": "somevals=",
      "public_members_url": "https://git.mycompany.com/api/v3/orgs/<gitorg>/public_members{/member}",
      "repos_url": "https://git.mycompany.com/api/v3/orgs/<gitorg>/repos",
      "url": "https://git.mycompany.com/api/v3/orgs/<gitorg>"
    },
    "ref": "refs/heads/master",
    "repository": {
      "archive_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/{archive_format}{/ref}",
      "archived": false,
      "assignees_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/assignees{/user}",
      "blobs_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/git/blobs{/sha}",
      "branches_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/branches{/branch}",
      "clone_url": "https://git.mycompany.com/<gitorg>/<gitrepo>.git",
      "collaborators_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/collaborators{/collaborator}",
      "comments_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/comments{/number}",
      "commits_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/commits{/sha}",
      "compare_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/compare/{base}...{head}",
      "contents_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/contents/{+path}",
      "contributors_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/contributors",
      "created_at": "2019-07-02T09:53:13Z",
      "default_branch": "master",
      "deployments_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/deployments",
      "description": null,
      "disabled": false,
      "downloads_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/downloads",
      "events_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/events",
      "fork": false,
      "forks": 0,
      "forks_count": 0,
      "forks_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/forks",
      "full_name": "<gitorg>/<gitrepo>",
      "git_commits_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/git/commits{/sha}",
      "git_refs_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/git/refs{/sha}",
      "git_tags_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/git/tags{/sha}",
      "git_url": "git://git.mycompany.com/<gitorg>/<gitrepo>.git",
      "has_downloads": true,
      "has_issues": true,
      "has_pages": false,
      "has_projects": true,
      "has_wiki": true,
      "homepage": null,
      "hooks_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/hooks",
      "html_url": "https://git.mycompany.com/<gitorg>/<gitrepo>",
      "id": 13021,
      "issue_comment_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/issues/comments{/number}",
      "issue_events_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/issues/events{/number}",
      "issues_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/issues{/number}",
      "keys_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/keys{/key_id}",
      "labels_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/labels{/name}",
      "language": "Shell",
      "languages_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/languages",
      "license": null,
      "merges_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/merges",
      "milestones_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/milestones{/number}",
      "mirror_url": null,
      "name": "<gitrepo>",
      "node_id": "somevalue==",
      "notifications_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/notifications{?since,all,participating}",
      "open_issues": 0,
      "open_issues_count": 0,
      "owner": {
        "avatar_url": "https://avatars.git.mycompany.com/u/2156?",
        "events_url": "https://git.mycompany.com/api/v3/users/<gitorg>/events{/privacy}",
        "followers_url": "https://git.mycompany.com/api/v3/users/<gitorg>/followers",
        "following_url": "https://git.mycompany.com/api/v3/users/<gitorg>/following{/other_user}",
        "gists_url": "https://git.mycompany.com/api/v3/users/<gitorg>/gists{/gist_id}",
        "gravatar_id": "",
        "html_url": "https://git.mycompany.com/<gitorg>",
        "id": 2156,
        "login": "<gitorg>",
        "node_id": "somevalue=",
        "organizations_url": "https://git.mycompany.com/api/v3/users/<gitorg>/orgs",
        "received_events_url": "https://git.mycompany.com/api/v3/users/<gitorg>/received_events",
        "repos_url": "https://git.mycompany.com/api/v3/users/<gitorg>/repos",
        "site_admin": false,
        "starred_url": "https://git.mycompany.com/api/v3/users/<gitorg>/starred{/owner}{/repo}",
        "subscriptions_url": "https://git.mycompany.com/api/v3/users/<gitorg>/subscriptions",
        "type": "Organization",
        "url": "https://git.mycompany.com/api/v3/users/<gitorg>"
      },
      "private": true,
      "pulls_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/pulls{/number}",
      "pushed_at": "2021-03-31T18:39:53Z",
      "releases_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/releases{/id}",
      "size": 339955,
      "ssh_url": "git@git.mycompany.com:<gitorg>/<gitrepo>.git",
      "stargazers_count": 1,
      "stargazers_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/stargazers",
      "statuses_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/statuses/{sha}",
      "subscribers_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/subscribers",
      "subscription_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/subscription",
      "svn_url": "https://git.mycompany.com/<gitorg>/<gitrepo>",
      "tags_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/tags",
      "teams_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/teams",
      "trees_url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>/git/trees{/sha}",
      "updated_at": "2021-03-31T18:39:56Z",
      "url": "https://git.mycompany.com/api/v3/repos/<gitorg>/<gitrepo>",
      "watchers": 1,
      "watchers_count": 1
    },
    "sender": {
      "avatar_url": "https://avatars.git.mycompany.com/u/5081?",
      "events_url": "https://git.mycompany.com/api/v3/users/<gituser>/events{/privacy}",
      "followers_url": "https://git.mycompany.com/api/v3/users/<gituser>/followers",
      "following_url": "https://git.mycompany.com/api/v3/users/<gituser>/following{/other_user}",
      "gists_url": "https://git.mycompany.com/api/v3/users/<gituser>/gists{/gist_id}",
      "gravatar_id": "",
      "html_url": "https://git.mycompany.com/<gituser>",
      "id": 5081,
      "login": "<gituser>",
      "node_id": "MDQ6VXNlcjUwODE=",
      "organizations_url": "https://git.mycompany.com/api/v3/users/<gituser>/orgs",
      "received_events_url": "https://git.mycompany.com/api/v3/users/<gituser>/received_events",
      "repos_url": "https://git.mycompany.com/api/v3/users/<gituser>/repos",
      "site_admin": false,
      "starred_url": "https://git.mycompany.com/api/v3/users/<gituser>/starred{/owner}{/repo}",
      "subscriptions_url": "https://git.mycompany.com/api/v3/users/<gituser>/subscriptions",
      "type": "User",
      "url": "https://git.mycompany.com/api/v3/users/<gituser>"
    },
    "workflow": ".github/workflows/imagebuild.yml"
  },
  "server_url": "https://git.mycompany.com",
  "api_url": "https://git.mycompany.com/api/v3",
  "graphql_url": "https://git.mycompany.com/api/graphql",
  "workspace": "/opt/actions-runner/_work/<gitrepo>/<gitrepo>",
  "action": "crazy-maxghaction-dump-context",
  "event_path": "/opt/actions-runner/_work/_temp/_github_workflow/event.json",
  "path": "/opt/actions-runner/_work/_temp/_runner_file_commands/add_path_2e4a0420-d3f0-40f8-b7a7-a2a44b12e781",
  "env": "/opt/actions-runner/_work/_temp/_runner_file_commands/set_env_2e4a0420-d3f0-40f8-b7a7-a2a44b12e781",
  "action_path": "/opt/actions-runner/_work/_actions/crazy-max/ghaction-dump-context/v1"
}

Dump job context
{
  "status": "success"
}

Dump steps context
{}

Dump strategy context
{
  "fail-fast": true,
  "job-index": 0,
  "job-total": 1,
  "max-parallel": 1
}

Dump matrix context
null

So basically git.mycompany.com "everywhere" properly but nevertheless its github.com here:

Run docker/build-push-action@v2
  with:
    push: false
    tags: user/app:latest
    pull: false
    no-cache: false
    load: false
    github-token: ***
  env:
    GITHUB_SERVER_URL: https://git.mycompany.com
📣 Buildx version: 0.5.1
🏃 Starting build...
/usr/bin/docker buildx build --tag user/app:latest --iidfile /tmp/docker-build-push-XiPuWS/iidfile --secret id=GIT_AUTH_TOKEN,src=/tmp/docker-build-push-XiPuWS/tmp-29931-s9nJ65dsS8js https://github.com/<gitorg>/<gitrepo>.git#heads/master
time="2021-03-31T20:41:00+02:00" level=warning msg="No output specified for docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load"
#1 [internal] load git source https://github.com/<gitorg>/<gitrepo>.git#heads/master
#1 sha256:651c08a1206dd80a55c8c9132f12adc937336da598a47e5fc5aa117b6078e979
#1 0.257 Initialized empty Git repository in /var/lib/buildkit/runc-overlayfs/snapshots/snapshots/1/fs/
#1 129.7 fatal: unable to access 'https://github.com/<gitorg>/<gitrepo>.git/': Failed to connect to github.com port 443: Operation timed out

But maybe (just guessing) it is overwritten here and should come out of the env var or the context instead (just as your first post suggests):

_defaultContext = `https://github.com/${github.context.repo.owner}/${

@crazy-max
Copy link
Member

@digitalkram

Yes just wanted to be sure github.server_url is populated with the right value in the context, which is the case so I'll be able to improve the default Git context for this action. This will give us:

_defaultContext = `${github.server_url}/${github.context.repo.owner}/${
  github.context.repo.repo
}.git#${github.context?.ref?.replace(/^refs\//, '')}`;

@codezninja
Copy link

@digitalkram I'm having a similiar issue. I saw this was just released. But still have the same issue even though I set the env in my workflow.yml. Is there a syntax I'm missing? I've tried both ways of setting this

Setting the environment variable on the specific action

      - name: Build and push
        id: docker_build
        uses: synced-actions/build-push-action@v2
        env:
          GITHUB_SERVER_URL: https://git.company.com

Setting the environment variable on the whole workflow

jobs:
  docker:
    runs-on: [self-hosted]
    env:
      GITHUB_SERVER_URL: https://git.mycompany.com
    steps:
      - name: Set up Docker Buildx
        uses: synced-actions/setup-buildx-action@v1

      - name: Build and push
        id: docker_build
        uses: synced-actions/build-push-action@v2
        with:
          push: true

@crazy-max
Copy link
Member

@bondezbond

I saw this was just released

Not yet shipped but you can test with docker/build-push-action@master in the meantime.

@codezninja
Copy link

sigh I need my coffee already :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants