Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"label": "GitHub More Topics",
"position": 7,
"link": {
"type": "generated-index",
"title": "GitHub More Topics for Absolute Beginners",
"description": "Explore more GitHub topics for absolute beginners, including advanced features, best practices, and tips to enhance your GitHub experience. Learn about branching, pull requests, GitHub Actions, and more to take your GitHub skills to the next level."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
title: "Introduction to GitHub Actions"
sidebar_label: "1. GitHub Actions"
sidebar_position: 1
description: "Learn how to automate your software development workflows directly in your GitHub repository. From running tests to deploying your website, GitHub Actions has you covered."
tags: ["github", "automation", "ci/cd", "devops", "workflow"]
keywords: ["github actions", "automation", "ci/cd", "devops", "workflow", "yml", "events", "jobs", "actions"]
---

In a professional workflow, we don't want to manually run tests or deploy our website every time we make a change. We want a system that does it for us.

**GitHub Actions** is an automation platform that allows you to create custom software development life cycle (SDLC) workflows directly in your GitHub repository.

:::info What is GitHub Actions?
GitHub Actions is a powerful tool that lets you automate tasks like testing, building, and deploying your code whenever certain events happen in your repository. It's like having a robot assistant that takes care of the repetitive tasks for you.
:::

## How it Works: The "Robot Assistant"

Think of GitHub Actions as a **Robot Assistant** that follows a simple rule:
> **"When [This Event] happens, do [This Job]."**

* **The Event:** Someone pushes code, opens a Pull Request, or even stars your repo.
* **The Job:** Run security scans, check for code errors, or deploy the site to a server.

## The Core Concepts

To master Actions at **CodeHarborHub**, you need to understand these four terms:

1. **Workflows:** The automated process (stored in a `.yml` file).
2. **Events:** The "Trigger" that starts the workflow (e.g., `push`).
3. **Jobs:** A set of steps that execute on the same runner (a virtual computer).
4. **Actions:** Reusable building blocks (like a "Login to AWS" block or "Install Node.js" block).

## Creating Your First Workflow

GitHub Actions are defined in **YAML** files. You must place them in a specific folder in your project: `.github/workflows/`.

```yaml title=".github/workflows/welcome.yml"
name: CodeHarborHub Welcome
on: [push] # The Trigger

jobs:
greet-developer:
runs-on: ubuntu-latest # The Virtual Machine
steps:
- name: Say Hello
run: echo "Automation is running successfully for CodeHarborHub!"
```

## The CI/CD Pipeline

GitHub Actions is most commonly used for **CI/CD**:

* **Continuous Integration (CI):** Automatically building and testing code so that errors are caught immediately when a developer pushes a branch.
* **Continuous Deployment (CD):** Automatically "Pushing" the code to a live server (like Vercel, Netlify, or AWS) after the tests pass.

## Why use Actions at CodeHarborHub?

| Benefit | Description |
| :--- | :--- |
| **No More "Works on my machine"** | Tests run on a clean cloud computer every time. |
| **Speed** | Robots work 24/7. Your site deploys the second you merge a PR. |
| **Security** | Automatically scan your code for leaked passwords or vulnerable packages. |
| **Free for Open Source** | GitHub provides free minutes for public repositories\! |

## Monitoring Your Actions

Once you push a workflow file, you can watch it run in real-time:

1. Go to your repository on GitHub.
2. Click the **Actions** tab.
3. Click on a specific "Workflow Run" to see the logs and status.

:::tip
Don't reinvent the wheel! Visit the [GitHub Marketplace](https://github.com/marketplace#type#Dactions) to find thousands of pre-written Actions created by the community that you can drop into your own projects.
:::
116 changes: 116 additions & 0 deletions absolute-beginners/git-github-beginner/more-github/github-cli.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
---
title: "Installing and Using GitHub CLI"
sidebar_label: "2. GitHub CLI (gh)"
sidebar_position: 2
description: "Learn how to install and use the GitHub CLI (gh) to manage your repositories, issues, and pull requests directly from the command line. This guide covers installation steps for Windows, macOS, and Linux, as well as essential commands to streamline your workflow."
tags: ["GitHub CLI", "gh", "Command Line", "GitHub Tools", "Developer Workflow"]
keywords: ["GitHub CLI", "gh", "Command Line Interface", "GitHub Tools", "Developer Workflow"]
---

While the GitHub website is beautiful and easy to use, professional developers often find it faster to perform tasks directly from the command line. The **GitHub CLI (`gh`)** is the official tool that brings GitHub’s issues, pull requests, and other features to your terminal.

At **CodeHarborHub**, we use `gh` to streamline our workflow and keep our focus on the code.

:::tip
Don't worry if you're new to the command line! The GitHub CLI is designed to be user-friendly, and this guide will help you get started step by step. By the end, you'll be able to manage your GitHub projects without ever leaving your terminal.
:::

## Why use the CLI?

1. **Context Switching:** You don't have to leave VS Code or your terminal to open a Pull Request.
2. **Automation:** You can write scripts to create repositories or check status automatically.
3. **Speed:** Most common actions (like cloning a repo or checking a PR) are 3x faster with a single command.

## Installation

<Tabs>
<TabItem value="windows" label="Windows" default>

Open PowerShell or Command Prompt and run:

```bash
winget install --id GitHub.cli
```

</TabItem>
<TabItem value="mac" label="macOS">

Use Homebrew:

```bash
brew install gh
```

</TabItem>
<TabItem value="linux" label="Linux">

For Debian/Ubuntu:

```bash
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh -y
```

</TabItem>
</Tabs>

## Getting Started: Authentication

Once installed, you need to link the CLI to your GitHub account. Run:

```bash
gh auth login
```

Follow the interactive prompts:

* Select **GitHub.com** (unless you're using GitHub Enterprise).
* Choose **HTTPS** or **SSH**.
* Select **Login with a web browser** (this will open a page to authorize the app).

## Essential Commands for Daily Work

| Task | Command | Description |
| :--- | :--- | :--- |
| **Repo Status** | `gh repo view` | Shows the README and basic info for the current repo. |
| **List PRs** | `gh pr list` | Lists all open Pull Requests in the repository. |
| **Check out PR** | `gh pr checkout <number>` | Downloads a teammate's PR to your PC to test it. |
| **Create PR** | `gh pr create` | Opens a new Pull Request for your current branch. |
| **View Issues** | `gh issue list` | Shows all open bugs or tasks. |

## Common Workflow Example

Imagine you want to start a new project for **CodeHarborHub**. Instead of clicking through the website:

1. **Create a new repo:**
```bash
gh repo create my-new-project --public --clone
```
2. **Change into the folder:**
```bash
cd my-new-project
```
3. **Open in VS Code:**
```bash
code .
```

*You just set up a full project in 5 seconds!*

## The "Status" View

One of the best features of `gh` is the **Dashboard** view. Run this to see everything happening with your work:

```bash
gh status
```

It shows your relevant Pull Requests, their review status, and if your **GitHub Actions** tests passed or failed.

:::tip
You can use the `--web` flag with almost any command (e.g., `gh pr view --web`) to instantly open that specific page in your browser if you need to see the full UI.
:::

This file was deleted.

Loading
Loading