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

Add Hub #36

Closed
3 of 5 tasks
tokiwong opened this issue Oct 14, 2019 · 13 comments
Closed
3 of 5 tasks

Add Hub #36

tokiwong opened this issue Oct 14, 2019 · 13 comments
Assignees
Labels
awaiting-deployment Code complete; awaiting deployment and/or deployment in progress OS: macOS OS: Ubuntu

Comments

@tokiwong
Copy link

tokiwong commented Oct 14, 2019

Tool information

  • Tool name: Hub
  • Add or update? Add
  • Desired version: 2.12.8 (latest)
  • Approximate size: 9.5 MB
  • If this is an add request:

Virtual environments affected

  • macOS 10.14
  • Ubuntu 16.04 LTS
  • Ubuntu 18.04 LTS
  • Windows Server 2016 R2
  • Windows Server 2019

Can this tool be installed during the build?
Yes, can be downloaded and installed from the github page

Are you willing to submit a PR?
Yes

@kaylangan
Copy link
Contributor

👋 Thanks for the suggestion! Are there specific hub commands that you're looking for? The extended git ones seem to be covered by having git installed, but some of the new commands offered by hub seem interesting.

Does actions/github-script offer the functionality you're looking for?

Duplicate of #1

@tokiwong
Copy link
Author

@kaylangan I'm specifically looking for hub pull-request

The idea is to have an action on repo A build a project and programmatically create a pull request with artifact changes to repo B, where repo B has its own GH Action that triggers on pull_request

@derek-burdick
Copy link

@kaylangan I'm looking for hub api repos/{owner}/{project}/issues/{issue}/comments so that I can post a comment to a Pull Request during an action.

Currently i'm manually downloading 2.12.8 in my Action steps.

@oldskool
Copy link

oldskool commented Nov 4, 2019

@kaylangan I'm looking for hub api repos/{owner}/{project}/issues/{issue}/comments so that I can post a comment to a Pull Request during an action.

You can also use the built-in GITHUB_TOKEN secret to directly talk to the API with a tool such as curl to achieve this, just add a step like:

steps:
  - name: Post comment
    env:
      API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      # If your workflow triggers on the pull_request event type,
      # you can access the PR number here
      PR_NUMBER: ${{ github.event.pull_request.number }}
    run: |
      curl -H "Authorization: token ${API_TOKEN}" \
      -XPOST -d '{"body": "Hello world"}' \
      https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments

This would remove the necessity to manually download Hub and save time on your build.

@derek-burdick
Copy link

As a follow up, if you have text that is not json friendly, you can use JQ to create a JSON document.
jq -nc --arg str "cat comment.txt" '{"body": $str}' > comment.json

then do -d @comment.json in curl.

I'm posting the output from terraform show to the pull request.

@knoopx
Copy link

knoopx commented Dec 6, 2019

There's no github action that allows to do something as simple as this:

      - env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          sudo snap install hub --classic
          build_date=$(date +%Y%m%d)
          build_number=$[$(git tag | grep $build_date | wc -l) + 1]
          tag="$build_date.$build_number"
          hub release create $tag --prerelease -m "$tag" -a dist/*.zip

Being able to do it without having to install hub each time would be awesome.

@oldskool
Copy link

oldskool commented Dec 6, 2019

There's no github action that allows to do something as simple as this:

I'm not quite sure how the create-release action would not allow you to do that?

@knoopx
Copy link

knoopx commented Dec 6, 2019

no offense but the create-release action is a joke. the snippet I pasted tags the just pushed commit using the current timestamp (20191206.1, 20191206.2, 20191207.1...), creates a release and attaches the first zip match as release asset. there's no easy, straightforward way to accomplish that, not even using a combination of several "official" actions.

no official actions:

  • allows to generate numeric sequences based on git/job/run/ time/history
  • allows to tag specific revisions

create-release:

  • requires and existing tag, no way to optionally tag on-demand

upload-release-asset:

  • does not support filename globs
  • you have to invoke it N times per file!
  • you need to specify asset_name, why?¿?
  • you need to specify content type, why?¿?
  • you need to specify upload_url, why?¿?

honestly, the "official" actions are very limited, they are just plain REST API wrappers over YAML syntax, inconvenient and with no extensibility in mind.

@peaceiris
Copy link

For reference. #1 (comment)

To download hub for Linux and place the executable into bin/hub of current directory (no need to install it system-wide just to be used in an action):

mislav/hub#2249 (comment)

wget -nv -O- \
  https://github.com/github/hub/releases/download/v2.12.7/hub-linux-amd64-2.12.7.tgz  | \
  tar xz --strip-components=1 '*/bin/hub'

@mislav
Copy link

mislav commented Jan 25, 2020

Added official instructions on how to download and use hub from within GitHub Actions

I wouldn't mind if hub was already bundled within the virtual environment, though!

@peaceiris
Copy link

Thank you!

@andy-mishechkin
Copy link
Contributor

andy-mishechkin commented Mar 16, 2020

Hub CLI has been added to building process of Ubuntu 16/18, MacOS, Windows images. After deployment you can use this utility in your builds.
Please feel free to reopen this issue if you'll detect some bugs.

@maxim-lobanov maxim-lobanov added awaiting-deployment Code complete; awaiting deployment and/or deployment in progress OS: macOS OS: Ubuntu labels Mar 17, 2020
@ydnar
Copy link

ydnar commented Mar 26, 2020

Verified it works. Thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-deployment Code complete; awaiting deployment and/or deployment in progress OS: macOS OS: Ubuntu
Projects
None yet
Development

No branches or pull requests