zer0

testing pr workflow again again, Damn it. I think i figured it out.

pages-build-deployment

Gem Version

This is the seed of the project with all the commands, scripts, and instructions that build this application from the ground up. In theory, this should be the only file you need to build the project from scratch. However, in practice, you may need to install additional dependencies or configure the environment to match the target system. For example, you may need to install Ruby, Node.js, or other tools to run the application locally or deploy it to a server. Therefore, part of this document is to provide a list of prerequisites and setup instructions to help you get started with the project.

System Specs

For my development machine, I use the following specs:

  • Model Name: MacBook Pro
  • Model Identifier: Mac15,6
  • Model Number: MRX33LL/A
  • Chip: Apple M3 Pro
  • System Firmware Version: 10151.101.3
  • System Version: macOS 14.4.1 (23E224)
  • Kernel Version: Darwin 23.4.0

Inspect the page to see the hidden code to populate your system specs for a MacBook pro. Press (cmd + shift + c) in the browser.

# Get specific hardware and software information for Macs

system_profiler SPHardwareDataType | awk '/Model Name:|Model Identifier:|Model Number:|Chip:|System Firmware Version:/ {print $0}'
system_profiler SPSoftwareDataType | awk '/System Version:|Kernel Version:/ {print $0}'

Prerequisites

Before we begin, make sure you have the following software installed on your machine:

  • VS code installed on your machine (if you’re smart)
  • docker installed on your machine (if you’re a pro)
  • homebrew installed on your machine (if you’re a cli junkie)
  • git installed on your machine (if you want to track the truth)
  • gh cli installed on your machine (if you want to publish the truth)

For step-by-step instructions on how to install these tools, visit the “Quickstart” section of the site here: Quickstart

To use these tools effectively, you need:

  • A GitHub account and a repository where you want to maintain and publish your site.
  • A personal access token from GitHub to authenticate with the GitHub API.
  • A cup of coffee or your favorite beverage to keep you energized.
  • A positive attitude and a sense of curiosity.
  • A sense of adventure and a willingness to explore new tools and technologies.
  • A growth mindset and a willingness to embrace challenges and learn from mistakes.
  • A sense of humor and the ability to laugh at unexpected errors and bugs.
  • A supportive community or network of friends and colleagues to ask for help and share your progress.
  • A clear goal and motivation to build this project and share your knowledge with the world.
  • A spirit of creativity and a desire to express yourself through code and technology.

More importantly, you need to:

  • Embrace responsibility and ethical, inclusive software development.
  • Cultivate empathy and create tools that benefit others.
  • Appreciate opportunities and resources for learning and growth.
  • Foster curiosity about AI and machine learning.
  • Pursue a purpose that enhances productivity and creativity.
  • Persevere through challenges with determination.
  • Learn from others and share knowledge with humility.
  • Believe in technology’s potential to improve lives and create positive change.
  • Make the learning process fun and engaging.
  • Balance work with breaks for well-being.
  • Celebrate achievements and share your work with the world.
  • Anticipate making a difference in the developer community.
  • Find satisfaction and fulfillment in creating value for others.
  • Connect with the global community of developers and creators.
  • Believe in your ability to create something meaningful and impactful.
  • Stand in awe of technology’s power to transform ideas into reality.

Confirm Prerequisites

Make sure you have the following installed on your machine:

# Check if git is installed
if ! git --version > /dev/null 2>&1; then
  echo "git is not installed. Installing..."
  brew install git
else
  echo "git is already installed."
fi

# Check if gh is installed
if ! gh --version > /dev/null 2>&1; then
  echo "gh is not installed. Installing..."
  brew install gh
else
  echo "gh is already installed."
fi

# Check if gh is authenticated
if ! gh auth status > /dev/null 2>&1; then
  echo "gh is not authenticated. Please authenticate..."
  gh auth login
else
  echo "gh is already authenticated."
fi

# Check if Docker is installed
if ! docker --version > /dev/null 2>&1; then
  echo "Docker is not installed. Installing..."
  brew install --cask docker
else
  echo "Docker is already installed."
fi

# Check if Visual Studio Code is installed
if ! code --version > /dev/null 2>&1; then
  echo "Visual Studio Code is not installed. Installing..."
  brew install --cask visual-studio-code
else
  echo "Visual Studio Code is already installed."
fi

Environment

Enter Variables

Define Environment Variables

Key Value
            export GITHOME=~/github
            
        

Or use default

# Or enter them in the terminal

echo "Please enter your GitHub username:"
read GHUSER
export GHUSER

echo "Please enter your Git repository name:"
read GIT_REPO
export GIT_REPO
export GITHOME=~/github
export GHUSER=$(gh api user --jq '.login')
export GIT_REPO=zer0-mistakes
export ZREPO=$GITHOME/$GIT_REPO
# Confirm the environment variables by echoing them and logging them to a file

echo "$(date) - Log started" > env-variables.log
echo -e "GITHOME: $GITHOME\nGHUSER: $GHUSER\nGIT_REPO: $GIT_REPO\nZREPO: $ZREPO" >> env-variables.log

Set Git email and username

# Set your Git email and name to tag your commits
# If the GIT_ID is set, use it to tag your commits. "https://github.com/settings/emails"

git config --global user.name "$GHUSER"
git config --global user.email "$GHUSER@users.noreply.github.com"
if [ -n "$GIT_ID" ]; then
  git config --global user.email "$GIT_ID+$GHUSER@users.noreply.github.com"
fi
# confirm your email

git config -l | tee -a env-variables.log

Initialize github

gh cli docs

# Create your github home directory and repo

mkdir -p $ZREPO
# Initialize your github repository

gh repo create $GIT_REPO --gitignore Jekyll -l mit --public
# If new repo, initialize it

cd $ZREPO
git init
git remote add origin https://github.com/${GHUSER}/${GIT_REPO}.git
git pull origin main

# Create a README.md file based on the zer0.md file from this repo
curl https://raw.githubusercontent.com/bamr87/it-journey/master/zer0.md > README.md
git add README.md
git commit -m "Init $GIT_REPO"
git branch -M main
git push -u origin main

Checkpoint - Github Repo

Go to your new github repository.

# Open your new github repository in the browser

open https://github.com/${GHUSER}/${GIT_REPO}

Checkpoint 1

Initialize Jekyll

Create Gemfile

# Create a new Gemfile
cd $ZREPO
touch Gemfile

# Write the non-commented lines to the Gemfile
echo 'source "https://rubygems.org"' >> Gemfile
echo "gem 'github-pages'" >> Gemfile
echo "gem 'jekyll-theme-zer0'" >> Gemfile
echo "group :jekyll_plugins do" >> Gemfile
echo "  gem 'jekyll-remote-theme', \"~> 0.4.3\"" >> Gemfile
echo "  gem 'jekyll-feed', \"~> 0.17\"" >> Gemfile
echo "  gem 'jekyll-sitemap' , \"~> 1.4.0\"" >> Gemfile
echo "  gem 'jekyll-seo-tag', \"~> 2.8.0\"" >> Gemfile
echo "  gem 'jekyll-paginate', \"~> 1.1\"" >> Gemfile
echo "end" >> Gemfile

Download Config file

# Download the _config.yml file from the jekyll-theme-zer0 repo

curl https://raw.githubusercontent.com/bamr87/zer0-mistakes/main/_config.yml > _config.yml

Create Dockerfile

# Create a new Dockerfile
cd $ZREPO
touch Dockerfile

# Write the content to the Dockerfile
echo "# Use an official Ruby runtime as a parent image" >> Dockerfile
echo "FROM ruby:2.7.4" >> Dockerfile
echo "# escape=\\" >> Dockerfile
echo "ENV GITHUB_GEM_VERSION 231" >> Dockerfile
echo "ENV JSON_GEM_VERSION 1.8.6" >> Dockerfile
echo "ENV GIT_REPO ${GIT_REPO}" >> Dockerfile
echo "WORKDIR /app" >> Dockerfile
echo "ADD . /app" >> Dockerfile
echo "RUN gem update --system 3.3.22" >> Dockerfile
echo "RUN bundle update" >> Dockerfile
echo "RUN bundle install" >> Dockerfile
echo "RUN bundle clean --force" >> Dockerfile
echo "EXPOSE 4000" >> Dockerfile
echo 'CMD ["bundle", "exec", "jekyll", "serve", "--verbose", "--host", "0.0.0.0"]' >> Dockerfile
# build the docker image based on the Dockerfile
docker build -t ${GIT_REPO} .
# Run the container in detached mode
docker run -d -p 4000:4000 -v ${ZREPO}:/app --name ${GIT_REPO}-container ${GIT_REPO}

# Start the container and run the CMD line from the Dockerfile
docker start ${GIT_REPO}-container

Checkpoint - Jekyll

open http://localhost:4000/${GIT_REPO}

Python Script

import os

def convert_md_to_files(md_file_path):
    language_files = {}
    language_mode = None
    language_extensions = {'python': '.py', 'shell': '.sh'}
    shebang_lines = {'python': '#!/usr/bin/env python3\n', 'shell': '#!/bin/bash\n'}

    output_folder = "script"
    os.makedirs(output_folder, exist_ok=True)

    with open(md_file_path, 'r') as md_file:
        for line in md_file:
            if line.startswith('```'):
                if language_mode:
                    # End of a language block, switch back to markdown mode
                    language_mode = None
                else:
                    # Start of a language block, open a new file for this language if not already open
                    language = line.strip('`\n')
                    if language in language_extensions:
                        language_mode = language
                        if language not in language_files:
                            output_file_path = os.path.join(output_folder, os.path.basename(md_file_path).replace('.md', language_extensions[language]))
                            language_file = open(output_file_path, 'w')
                            if language in shebang_lines:
                                language_file.write(shebang_lines[language])
                            language_files[language] = language_file
                continue

            if language_mode:
                language_files[language_mode].write(line)

    # Close all open language files
    for language_file in language_files.values():
        language_file.close()

convert_md_to_files('zer0.md')

Config file

# Welcome to Jekyll!
# Configuration file for Jekyll.
# Full docs at: http://jekyllrb.com/docs/configuration/
# YAML docs at: https://yaml.org/spec/1.2.2/
# ---------------------------------------------------------------------------------
#
# This config file is meant for settings that affect your whole blog, values
# which you are expected to set up once and rarely edit after that. If you find
# yourself editing this file very often, consider using Jekyll's data files
# feature for the data you need to update frequently.
#
# For technical reasons, this file is *NOT* reloaded automatically when you use
# 'bundle exec jekyll serve'. If you change this file, please restart the server.
#
# If you need help with YAML syntax, here are some quick references for you: 
# https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml
# https://learnxinyminutes.com/docs/yaml/
#
# You can find config options at: https://jekyllrb.com/docs/configuration/options/
#
# These are used to personalize your new site. If you look in the HTML files,
# you will see them accessed via IT-Journey, amr@it-journey.dev, and so on.
# You can create any custom variable you would like, and they will be accessible
# in the templates via .


# Site Settings ###################################################################

founder                  : "Amr Abdel-Motaleb"
remote_theme             : "bamr87/zer0-mistakes"
# theme                    : "jekyll-theme-zer0"

## Github Information
github_user              : &github_user "bamr87"
repository_name          : &github_repository "it-journey"
repository               : [*github_user, "/", *github_repository] # GitHub username/repo-name
local_repo               : *github_repository
branch                   : "main"
repo_map                 : "/about/sitemap/"
github_base_url          : [*github_user, '.' , *site_domain] # the base hostname & protocol for your site, e.g. http://example.com
portfolio                : [*github_user, '.', 'github.io']

## Site Information ---------------------------------------------------------------

title                    : IT-Journey
title_url                : "/"
title_icon               : "globe"
subtitle                 : "zer0 to her0"
subtitle_url             : "localhost"
subtitle_icon            : "code"
title_separator          : "|" # Appears in the web browser tab name
domain                   : &domain "it-journey"
domain_ext               : ".dev"
sub_domain               : &sub_domain ""
baseurl                  : "" # the subpath of your site, e.g. /blog - Use this if you want this whole repo to be a domain branch
url_dev                  : ['https://', *sub_domain, '.', *domain, *domain_ext ] # the base hostname & protocol for your site, e.g. http://example.com
url                      : &url 'https://it-journey.dev' # the base hostname & protocol for your site, e.g. http://example.com
public_folder            : "/assets"
port                     : 4002 # Jekyll Serve Dev port
dg_port                  : 4001 # TODO: Doppelganger site. Use this if you want to switch between parallel deployments
og_image                 : '/assets/images/wizard-on-journey.png'

### Owner Information -------------------------------------------------------------

name                     : &name "Amr"
email                    : "amr@it-journey.dev"
description              : >- # this means to ignore newlines until the next variable
  Collection of articles, notes, and tutorials to build a website
  or headless CMS using Jekyll and Github Pages.
  This is my journey from zer0 to her0.
level                    : 'her0'


# Maintainer Information----------------------------------------------------------

maintainers:
  - name: *name
    profile: ["https://github.com", "/", *github_user]
  - name: "Vacant"
    profile: "/github.com"

## Personalization ----------------------------------------------------------------

locale                   : "en-US"
home_dir                 : &home '/Users/bamr87/'
local_git                : [ *home, 'github' ]
logo                     : /assets/images/gravatar-small.png  # path of logo image to display in the masthead, e.g. "/assets/images/88x88.png"
logo_link                : [ *url, *baseurl ] # URL to link the logo to, e.g. "/"

teaser                   : /assets/images/favicon_gpt_computer_retro.png # path of fallback teaser image, e.g. "/assets/images/500x300.png"
info_banner              : /assets/images/info-banner-mountain-wizard.png # path of fallback teaser image, e.g. "/assets/images/500x300.png"
breadcrumbs              : true # true, false (default)
words_per_minute         : 200
_posts_file_structure    : "year-month-day-title.md"

## Identity #####################################################################

author:
  name                   : *name # *name is a YAML reference pointing to the &anchor earlier
  avatar                 : "/assets/images/gravatar-small.png"
  email_hash             : '71d7a4fc9712df49e13d606e620f89c7' # https://en.gravatar.com/site/check/{ site.email }
  gravatar               : [ 'https://s.gravatar.com/avatar/', *email_hash, '?s=80' ]
  bio                    : "IT nerd trying to be an IT hero"
  location               : "Denver, CO"
  twitter_username       : "bamr87"
  github_username        : *github_user


## Site Analytics #############################################################

google_analytics         : 'G-ZBDKNMC168'

## Site verification #############################################################

google_site_verification : null
bing_site_verification   : null
alexa_site_verification  : null
yandex_site_verification : null
aver_site_verification   : null
baidu_site_verification  : null

## Affiliations ##############################################################

default_icon: "bi" ## Bootstrap Icons https://icons.getbootstrap.com/

links:
  - label: "BASH Consulting"
    url: "https://bashconsultants.com"
    icon: "bi-link"
  - label: "Twitter"
    icon: "bi-twitter"
    url: "https://twitter.com/bamr87"
  - label: "GitHub"
    icon: "bi-github"
    url: [ 'https://github.com/' , *github_user ]
  - label: "Instagram"
    icon: "bi-instagram"
    url: "https://instagram.com/bamr42"

youtube:
  - label: "YouTube"
    icon: "bi-youtube"
    url: "https://www.youtube.com/channel/UCO0j3Opg3J9i2iWnDwHUsXQ"

## Build Framework ##############################################################

powered_by:
  - name: "Ruby"
    version: "2.7.4"
    url: "https://www.ruby-lang.org/"
    icon: "bi-gem"
  - name: "Jekyll"
    version: "3.9.5"
    url: "https://jekyllrb.com/"
    icon: "bi-joystick"
  - name: "Bootstrap"
    version: "5.2.0"
    url: "https://getbootstrap.com/"
    icon: "bi-bootstrap"
  - name: "Algolia"
    version: 
    url: "https://algolia.com/"
    icon: "bi-search"
  - name: "JQuery"
    url: "https://jquery.com/"
    icon: "bi-filetype-js"
  - name: "MathJax"
    version: "1.0"
    url: "https://www.mathjax.org/"
    icon: "bi-calculator"
  - name: "GitHub Pages"
    version: "231"
    url: "https://pages.github.com/"
    icon: "bi-github"
  - name: "docker"
    version: "20.10.8"
    url: "https://www.docker.com/"
    icon: "bi-docker"

### Plugins  #####################################################################

# https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/about-github-pages-and-jekyll#plugins
# http://jekyllrb.com/docs/plugins/

# All plugins are enabled by default for GitHub Pages. https://pages.github.com/versions/

plugins:
  - github-pages
  - jekyll-remote-theme
  - jekyll-feed
  - jekyll-sitemap
  - jekyll-seo-tag
  - jekyll-paginate
  - jekyll-relative-links

## Gisgus Plugin #################################################################

gisgus:
  enabled: true
  data-repo-id: "MDEwOlJlcG9zaXRvcnkyODM4MjI1NzM"
  data-category-id: "DIC_kwDOEOrJ7c4CAn8D"

# https://github.blog/2022-02-14-include-diagrams-markdown-files-mermaid/

## Conversion
# Markdown Options https://jekyllrb.com/docs/configuration/markdown/
# https://github.com/github/jekyll-commonmark-ghpages

markdown: kramdown
# highlighter: rouge
# lsi: false
# excerpt_separator: "\n\n"
# incremental: false

# Markdown Processing https://jekyllrb.com/docs/configuration/markdown/
kramdown: # https://kramdown.gettalong.org/options.html
  input: GFM
  header_offset: 0
  # hard_wrap: false
  # auto_ids: true
  # footnote_nr: 1
  # entity_output: as_char
  toc_levels: 1..6
  # smart_quotes: lsquo,rsquo,ldquo,rdquo
  # enable_coderay: false

# Collections: https://jekyllrb.com/docs/collections/
  # Permalinks: https://jekyllrb.com/docs/permalinks/

collections_dir: &collections_dir pages
local_repo_path: [ *collections_dir, '/', *local_repo ]

collections:
  pages:
    output: true
    permalink: /:collection/:name/
  posts:
    output: true
    permalink: /:collection/:year/:month/:day/:slug/
  docs:
    output: true
    permalink: /:collection/:categories/:name/
  quests:
    output: true
    permalink: /:collection/:categories/:name/
  hobbies:
    output: true
    permalink: /:collection/:categories/:name/
  notebooks:
    output: true
    permalink: /:collection/:path/:name/
  notes:
    output: true
    permalink: /:collection/:path/:name/
  quickstart:
    output: true
    permalink: /:collection/:categories/:name/
  about:
    output: true
    permalink: /:collection/:categories/:name/

permalink: pretty

#  pagination https://jekyllrb.com/docs/pagination/

paginate: 10
paginate_path: "/pages/:num/"

# Defaults https://jekyllrb.com/docs/configuration/front-matter-defaults/

defaults:
  # ALL
  - 
    scope:
      path: ""
    values:
      layout: root
      author_profile: false
      read_time: true
      comments: false # true
      share: true
      related: true
      sidebar:
        nav: main
    permalink: /:collection/:name/

  # pages
  - 
    scope:
      path: pages
    values:
      layout: &pages default
      author_profile: true
      read_time: true
      comments: # true
      share: true
      related: true
      toc_sticky: true
      sidebar:
        nav: searchCats
    permalink: /:path/:name/

  # pages/_about
  - 
    scope:
      path: pages/_about
    values:
      layout: *pages
      collection: about
      share: true
      related: true
      sidebar:
        nav: about

  # pages/_quickstart
  - 
    scope:
      path: pages/_quickstart
    values:
      layout: default
      collection: quickstart
      share: true
      related: true
      sidebar:
        nav: quickstart

  # pages/_posts
  - 
    scope:
      path: pages/_posts
    values:
      layout: journals
      author_profile: true
      read_time: true
      comments: # true
      share: true
      related: true
      sidebar:
        nav: dynamic
      # permalink: /:collection/:name/

  # pages/_docs
  - 
    scope:
      path: pages/_docs
    values:
      layout: *pages
      # category: docs
      author_profile: true
      read_time: true
      comments: # true
      share: true
      related: true
      sidebar:
        nav: docs
    # permalink: /docs/:category/:name/

  # pages/_quests
  - 
    scope:
      path: pages/_quests
    values:
      layout: *pages
      author_profile: true
      read_time: true
      comments: # true
      share: true
      related: true
      sidebar:
        nav: dynamic
      permalink: /:categories/:slug

  # pages/_hobbies
  - 
    scope:
      path: pages/_hobbies
      type: hobbies
    values:
      layout: *pages
      share: false
      author_profile: false
      sidebar:
        nav: hobbies

  # pages/_notes
  - 
    scope:
      path: pages/_notes
      type: notes
    values:
      layout: *pages
      share: false
      author_profile: false
      sidebar:
        nav: dynamic

# Exclude from processing.
# The following items will not be processed, by default.
# Any item listed under the `exclude:` key here will be automatically added to
# the internal "default list".
#
# Excluded items can be processed by explicitly listing the directories or
# their entries' file path in the `include:` list.

exclude:
  - .sass-cache/
  - .jekyll-cache/
  - .obsidian
  - Gemfile.lock
  - gemfiles/
  - Gemfile
  - node_modules/
  - vendor/
  # - "*.sh"
  - submodules/

# Sass/SCSS
sass:
  sass_dir: _sass
  style: expanded

#  TODO: Fix bootstrap plugin
  # load_paths:
  #   - /usr/local/bundle/gems/bootstrap-5.3.3/assets/stylesheets

algolia:
  application_id: 'SP02Z3YYL4'
  search_only_api_key: '3b9200e21085fbebc263950c157b2682'
  index_name: dev_it-journey

## Style Settings -------------------------------------------------------------

# theme                  : "zer0-mistakes-jekyll"
# remote_theme           : "bamr87/zer0-mistakes"
theme_skin               : "dark" # "air", "aqua", "contrast", "dark", "dirt", "neon", "mint", "plum", "sunrise"

# style                  : "default" # "default", "dark", "light", "solarized-dark", "solarized-light"
# remote_style           : "bamr87/zer0-mistakes"

theme_color:
  main: #007bff
  secondary: #6c757d
  red: #a11111
  yellow: #ffe900
  teal: #376986
  blue: #007bff
  green: #28a745
  purple: #6f42c1
  pink: #e83e8c
  orange: #fd7e14
  brown: #795548
  cyan: #17a2b8
  indigo: #6610f2
  lime: #cddc39
  amber: #ffc107
  deep_orange: #ff5722
  deep_purple: #673ab7
  light_blue: #03a9f4
  light_green: #8bc34a
  light_purple: #9c27b0
  light_red: #f44336
  light_yellow: #ffeb3b
  light_teal: #009688

## Copyright Settings --------------------------------------------------------------

cr_year: 2024
cr_entity: *name
cr_lisense: "MIT"

## Sitemap Settings --------------------------------------------------------------

# sitemap_include: A list of file extensions that should be included in the sitemap. By default, HTML files and any files with sitemap: true in their front matter are included.
# sitemap_exclude: A list of files or directories that should be excluded from the sitemap.

sitemap_include: ["html", "xml"]
sitemap_exclude: ["secret.html", "private"]

Scripts

#!/bin/bash
# Get specific hardware and software information for Macs

system_profiler SPHardwareDataType | awk '/Model Name:|Model Identifier:|Model Number:|Chip:|System Firmware Version:/ {print $0}'
system_profiler SPSoftwareDataType | awk '/System Version:|Kernel Version:/ {print $0}'

# install and update prerequisites

brew install git
brew install gh
brew install --cask docker
brew install --cask visual-studio-code
# Or enter them in the terminal

echo "Please enter your GitHub username:"
read GHUSER
export GHUSER

echo "Please enter your Git repository name:"
read GIT_REPO
export GIT_REPO
export GITHOME=~/github
export ZREPO=$GITHOME/$GIT_REPO
# Confirm the environment variables by echoing them and logging them to a file

echo "$(date) - Log started" > env-variables.log
echo -e "GITHOME: $GITHOME\nGHUSER: $GHUSER\nGIT_REPO: $GIT_REPO\nZREPO: $ZREPO" >> env-variables.log
# Set your Git email and name to tag your commits
# If the GIT_ID is set, use it to tag your commits. "https://github.com/settings/emails"

git config --global user.name "$GHUSER"
git config --global user.email "$GHUSER@users.noreply.github.com"
if [ -n "$GIT_ID" ]; then
  git config --global user.email "$GIT_ID+$GHUSER@users.noreply.github.com"
fi
# confirm your email

git config -l | tee -a env-variables.log
# Create your github home directory and repo

mkdir -p $ZREPO
# Initialize your github repository

gh repo create $GIT_REPO --gitignore Jekyll -l mit --public
# If new repo, initialize it

cd $ZREPO
git init
git remote add origin https://github.com/${GHUSER}/${GIT_REPO}.git
git pull origin main

# Create a README.md file based on the zer0.md file from this repo
curl https://raw.githubusercontent.com/bamr87/it-journey/master/zer0.md > README.md
git add README.md
git commit -m "Init $GIT_REPO"
git branch -M main
git push -u origin main
# Open your new github repository in the browser

open https://github.com/${GHUSER}/${GIT_REPO}

# Create a new Gemfile
cd $ZREPO
touch Gemfile

# Write the non-commented lines to the Gemfile
echo 'source "https://rubygems.org"' >> Gemfile
echo "gem 'github-pages' , '231'" >> Gemfile
echo "gem 'jekyll' , '3.9.5'" >> Gemfile
echo "gem 'jekyll-theme-zer0'" >> Gemfile
echo "group :jekyll_plugins do" >> Gemfile
echo "  gem 'jekyll-feed', \"~> 0.17\"" >> Gemfile
echo "  gem 'jekyll-sitemap' , \"~> 1.4.0\"" >> Gemfile
echo "  gem 'jekyll-seo-tag', \"~> 2.8.0\"" >> Gemfile
echo "  gem 'jekyll-paginate', \"~> 1.1\"" >> Gemfile
echo "end" >> Gemfile
# Download the _config.yml file from the jekyll-theme-zer0 repo

curl https://raw.githubusercontent.com/bamr87/zer0-mistakes/main/_config.yml > _config.yml
# Create a new Dockerfile
cd $ZREPO
touch Dockerfile

# Write the content to the Dockerfile
echo "# Use an official Ruby runtime as a parent image" >> Dockerfile
echo "FROM ruby:2.7.4" >> Dockerfile
echo "# escape=\\" >> Dockerfile
echo "ENV GITHUB_GEM_VERSION 231" >> Dockerfile
echo "ENV JSON_GEM_VERSION 1.8.6" >> Dockerfile
echo "ENV GIT_REPO ${GIT_REPO}" >> Dockerfile
echo "WORKDIR /app" >> Dockerfile
echo "ADD . /app" >> Dockerfile
echo "RUN gem update --system 3.3.22" >> Dockerfile
echo "RUN bundle update" >> Dockerfile
echo "RUN bundle install" >> Dockerfile
echo "RUN bundle clean --force" >> Dockerfile
echo "EXPOSE 4000" >> Dockerfile
echo 'CMD ["bundle", "exec", "jekyll", "serve", "--host", "0.0.0.0"]' >> Dockerfile
# build the docker image based on the Dockerfile
docker build -t ${GIT_REPO} .
# Run the container in detached mode
docker run -d -p 4000:4000 -v ${ZREPO}:/app --name zer0_container ${GIT_REPO}

# Start the container and run the CMD line from the Dockerfile
docker start zer0_container

open http://localhost:4000/