GithubHelp home page GithubHelp logo

global-localhost / github Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fulll/github

0.0 0.0 0.0 62 KB

An (unofficial) Github command line client (based on Api V3) :octocat:

License: MIT License

Go 52.99% Shell 47.01%

github's Introduction

An (unofficial) Github command line client

Go Report Card Twitter

This command line client is based on Github API V3.

What it does

You can manipulate following Github resources:

What it will (probably) never do

Managing resources like pull requests, issues or repositories life cycle and settings for example.

Some very good tools like hub or terraform provider are already great at doing that.

How to install it?

go get github.com/inextensodigital/github

or you can use the install script:

curl -qs https://raw.githubusercontent.com/inextensodigital/github/master/install.sh | bash -

or a simplified version (feel free to replace linux by either windows or darwin)

curl -s https://api.github.com/repos/inextensodigital/github/releases/latest |
jq -r '.assets[] | select(.name | test("linux-amd64$")) | .browser_download_url' |
wget -qi - -O github && chmod +x github

Why another Github client?

The goal is to have a convenient, lightweight tool to use inside github actions v2 workflows.

Some use cases that motivated the creation of this tool were:

How it can help you in github actions v2?

Continuous deployment on staging

name: trigger staging deployment on pull request merged
on:
  push:
    branches: [master, dev]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - run: echo build app
      - run: curl -qs https://raw.githubusercontent.com/inextensodigital/github/master/install.sh | bash -
      - id: deployment
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          id=$(github deployment create --productionEnvironment=false --environment staging $GITHUB_REF)
          github deployment_status create $id in_progress
          echo "##[set-output name=deployment_id;]$id"
      - env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          ID: ${{ steps.deployment.outputs.deployment_id }}
        run: |
          echo deploy app
          github deployment_status create $ID success
      - if: failure()
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          ID: ${{ steps.deployment.outputs.deployment_id }}
        run: github deployment_status create $ID failure

Continuous delivery on production

name: create production deployment on release published
on: release
jobs:
  is-published:
    runs-on: ubuntu-latest
    steps:
      - if: github.event.action != 'published'
        run: exit 1
  build:
    runs-on: ubuntu-latest
    needs: is-published
    steps:
      - run: echo build app
  create-deployment:
    runs-on: ubuntu-latest
    needs: build
    steps:
      # # optional: install hub
      # - run: |
      #     curl -s https://api.github.com/repos/github/hub/releases/latest |
      #     jq -r '.assets[] | select(.name | contains("linux-amd64")) | .browser_download_url' |
      #     wget -qi - -O - | sudo tar xzpf - -C / --strip-components=1
      # - uses: actions/checkout@master
      - run: curl -qs https://raw.githubusercontent.com/inextensodigital/github/master/install.sh | bash -
      - id: deployment
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          id=$(github deployment create $GITHUB_REF)
          echo "##[set-output name=deployment_id;]$id"
      # #-----------------------------8<----------------------------------------
      # # here: some job(s) to add for example a deploy button/process
      # - uses: some-deploy-button-action
      #   id: button
      #   with:
      #     deployment_id: ${{ steps.deployment.outputs.deployment_id }}
      # - name: append button to release note
      #   env:
      #     DEPLOY_BUTTON: ${{ steps.button.outputs.release-button }}
      #     TAG_NAME: ${{ github.event.release.tag_name }}
      #     GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      #     GITHUB_USER: ${{ github.actor }}
      #   run: |
      #     button=$(printf '\n## Deploy to production :rocket:\n%s\n' "$DEPLOY_BUTTON")
      #     hub release edit -m "" -m "$(hub release show $TAG_NAME -f %b)" -m "$button" $TAG_NAME
      # #-----------------------------8<----------------------------------------

Then, some external approbation process put the deployment status to in_progress and you effectively deploy on production ๐ŸŽ‰

name: deploy on production
on: deployment_status
jobs:
  should-deploy:
    runs-on: ubuntu-latest
    steps:
      - if: github.event.deployment.original_environment != 'production' || github.event.deployment_status.state != 'in_progress'
        run: exit 1
  deploy:
    needs: should-deploy
    runs-on: ubuntu-latest
    steps:
      - run: curl -qs https://raw.githubusercontent.com/inextensodigital/github/master/install.sh | bash -
      - env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          ID: ${{ github.event.deployment.id }}
        run: |
          echo deploy app
          github deployment_status create $ID success
      - if: failure()
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          ID: ${{ github.event.deployment.id }}
        run: github deployment_status create $ID failure

github's People

Contributors

hadeli avatar vibou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.