diff --git a/README.md b/README.md index e5ffc81..8988691 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,53 @@ ![App icon](images/FullSizeIcon.png) # VersionTwo + Hackathon project: CLI tool to generate static planning view of issues for better team planning -# ๐Ÿš€ Getting Started -## ๐Ÿ“ฆ Requirements +## ๐Ÿš€ Getting Started + +### ๐Ÿ“ฆ Requirements + The following dependencies are required to run the program: + - Python 3.x - `brew install python3` - Python `pyenv` and `pyenv-virtualenv` - - `brew install pyenv pyenv-virtualenv` + - `brew install pyenv pyenv-virtualenv` - GitHub Command Line Interface (CLI) `gh` - `brew install gh` -## ๐Ÿ’ป Setup +### ๐Ÿ’ป Setup + - Authentication through `gh auth login` -- Set the appropriate token permissions: `gh auth refresh --scopes read:project` - - Note: The team must have `read` permissions on the Project Board in order to view the issues on the board. -- Set the `GITHUB_TOKEN` environment variable: `export GITHUB_TOKEN=$(gh auth token)` -- Set the `GITHUB_UNAME` environment variable: `export GITHUB_UNAME=$(gh auth status | grep "(GITHUB_TOKEN)" | cut -d " " -f9)` +- Source the [setup-gh.sh](src/setup-gh.sh) script to configure your gh environment variables + + ```bash + source src/setup-gh.sh # follow the prompts + ``` + + - Sets the appropriate token scopes: `read: project`. + - Note: The team must have `read` permissions on the Project Board in order to view the issues on the board. + - Sets the `GITHUB_TOKEN` environment variable. + - Sets the `GITHUB_UNAME` environment variable. - Run `make install` inside the repo directory to configure the appropriate versions of dependencies. -## ๐Ÿ›  Usage +### ๐Ÿ›  Usage + To run the main script, change to the current directory of the script, then run: `python version2.py --output-file "" --temp-dir "" --include-project ` See the `--help` menu for full list of filter functionality. -# Background +## Background + GitHub users have issues assigned to themselves or a team they are a member of. These issues can be viewed on a Project board, which captures the issues in swim lanes. The Project board can only automate with a single organization, meaning users who work in more than one org do not have a single location to view all issues. This leads to fragmented planning and execution. -# How does it work? +## How does it work? ```mermaid %% A ยท System-Architecture Diagram (โ‰ค25 nodes) @@ -52,7 +65,8 @@ classDef api fill:#e3f2fd,stroke:#2196f3; classDef cli fill:#f1f8e9,stroke:#7cb342; ``` -# Our Solution +## Our Solution + Our python script will query the GitHub API for all issues associated with the appropriate filters provided to the CLI tool. The output will be a static HTML page showing all issues in swim lanes. This provides a comprehensive overview -of all issues the team or user has assigned. +of all issues the team or user has assigned. diff --git a/src/setup-gh.sh b/src/setup-gh.sh new file mode 100644 index 0000000..05799d3 --- /dev/null +++ b/src/setup-gh.sh @@ -0,0 +1,43 @@ +#! /usr/bin/env bash + +# This script sets up the authentication parameters for the GitHub CLI +# that are needed to run the version2.py script. +# It is assumed that the GitHub CLI is already installed and configured +# on the system. +# The script will update the user's github token to have the needed scopes, +# set the token in the environment and pull in the gh users username as +# another environment variable. + +# Exit if not sourced +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + echo "ERROR: This script must be sourced, not executed." + echo "Usage: source ${BASH_SOURCE[0]}" + exit 1 +fi + +# Check if the GITHUB_TOKEN environment variable is already set +set_gh_token() { + # If not set, set the scopes for the token and set the environment variable + gh auth refresh --scopes read:project + + # Set the GITHUB_TOKEN environment variable + export GITHUB_TOKEN=$(gh auth token) +} + +configure_gh_env() { + if [ -n "${GITHUB_TOKEN}" ]; then + echo "GITHUB_TOKEN needs to be unset to update the token scopes." + unset GITHUB_TOKEN + fi + + # set the gh_token + set_gh_token + + # set the gh_user + export GITHUB_UNAME=$(gh api user --jq .login) + + echo "GITHUB_TOKEN is set. Length is: ${#GITHUB_TOKEN}" + echo "GITHUB_UNAME is set to: ${GITHUB_UNAME}" +} + +configure_gh_env