GitHub Essentials

Why read this? The workshop uses GitHub features as if you already know them. This is the 10-minute crash course β€” enough to be comfortable, with worked examples you can try on your own fork.


🧭 The mental model

flowchart TB
  UP["The original repository<br/>HybridCloudWorks/Demo-IaC_Demo_with_VSCode"]
  FORK["Your fork<br/>your own copy, your own Actions"]

  subgraph INSIDE["What lives inside a repository"]
    REPO["Code<br/>the Bicep templates and scripts"]
    WIKI["docs/wiki<br/>these pages, published with GitHub Pages"]
    ACT["Actions<br/>the workflows that deploy"]
    CFG["Settings Β· Secrets and variables<br/>configuration the workflows read"]
  end

  UP -->|"you fork it, once"| FORK
  FORK --- INSIDE
  ACT -->|"reads at run time"| CFG
  ACT -->|"checks out"| REPO

  classDef net fill:#eef4ff,stroke:#4472c4,color:#1a1a1a
  classDef compute fill:#eefaf0,stroke:#3a9d5d,color:#1a1a1a
  classDef data fill:#f5eefc,stroke:#7c4dbe,color:#1a1a1a
  class UP,FORK net
  class REPO,WIKI compute
  class ACT,CFG data

Text description of this diagram</summary>

A repository is a project folder GitHub tracks with git. Forking makes your own complete copy, with its own Actions runs and its own secrets β€” which is why every participant works in a fork rather than sharing one repo.

Four things live inside it and matter here. Code is the Bicep templates and scripts. Actions are the workflows that deploy them. Settings β†’ Secrets and variables holds the configuration those workflows read at run time β€” secrets are masked in logs, variables are not. These pages are Markdown files in the repository’s docs/wiki/ folder, published as a GitHub Pages site.

One thing the picture can’t show: your fork copies these pages too, but it does not publish them unless you turn on Pages for it β€” which is why these pages always link back to the original repository.

</details>


πŸ“¦ Repository

A repository (β€œrepo”) is a project folder that GitHub tracks with git β€” every change is a commit and the full history is kept forever.

Term What it means
Fork Your personal copy of someone else’s repo, under your account. You need a fork here because Actions runs belong to the repo they run in β€” your fork gets its own runs, its own configuration, and its own federated deploy credential.
Clone Download the repo to your machine so you can edit it (gh repo clone <owner>/<repo> or GitHub Desktop).
Commit / push Save a set of changes (commit) and upload them to GitHub (push).
Branch A parallel line of work. This workshop deploys from main.

Try it: on your fork, edit README.md, commit with a message like docs: my first edit, and push. Watch it appear under the repo’s Commits.


βš™οΈ Actions (automation)

GitHub Actions runs automation defined in YAML files under .github/workflows/. Each file is a workflow; a workflow has jobs; a job has steps.

[!NOTE] This repo’s workflows are all manual β€” they use on: workflow_dispatch, so they only run when you click Run workflow. Nothing deploys by surprise.

Key anatomy (from curriculum-l1-1-core-deployment.yml):

Part What it does
on: workflow_dispatch Manual trigger β€” only runs when you click the button
permissions: id-token: write Allows the run to request an OIDC token for passwordless Azure login
concurrency: Prevents two runs of the same lab from clobbering each other
steps: checkout β†’ resolve resource group & prefix β†’ Azure login β†’ lint β†’ what-if β†’ deploy

Try it: Actions β†’ Curriculum L1.1 - Core Deployment β†’ Run workflow β†’ expand the What-if step to see what would be created.

Actions on forks are disabled by default. The first time you visit the Actions tab on your fork, GitHub will ask you to enable them β€” click the green button.

Learn more: https://docs.github.com/actions


πŸ“ Docs site (GitHub Pages)

These pages (what you are reading) are Markdown files in the repo’s docs/wiki/ folder. On every push to main that changes them, the Docs site workflow (.github/workflows/pages.yml) builds them with Jekyll and publishes them with GitHub Pages.

  • Edit a page like any other file: change it on a branch and open a pull request.
  • Links between pages use the file name, [L1.1](/Demo-IaC_Demo_with_VSCode/Curriculum-L1-1-Core-Deployment.html), and the site turns that into a link to the published page.

πŸ” Secrets vs. Variables

Both live under Settings β†’ Secrets and variables β†’ Actions in your fork, and both feed values into workflows. They are not interchangeable.

Β  Secret Variable
Purpose Sensitive values Non-sensitive config
Visible after saving? Never β€” write-only, masked in logs Yes, fully readable
Used in YAML as ${{ secrets.NAME }} ${{ vars.NAME }}
Names this workshop recognizes AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_SUBSCRIPTION_ID, AZURE_RESOURCE_GROUP, VM_ADMIN_PASSWORD, SQL_ADMIN_PASSWORD AZURE_PREFIX, AZURE_LOCATION, ALERT_EMAIL (the three IDs also work as variables)

[!TIP] Rule of thumb: if someone leaking it could cause harm, it is a secret. If you would happily print it in a log, it is a variable.

The IDs (AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_SUBSCRIPTION_ID) are stored as secrets not because they are dangerous alone, but so they are auto-masked in logs. That is a common, sensible convention.

Worked example β€” secrets with defaults

Here is the twist this workshop teaches: most values have a sensible default, so a classroom fork needs almost nothing set. The workflows read values through a fallback expression β€” secret if present, sensible default if not. From the real curriculum-l1-1-core-deployment.yml:

env:
  AZURE_CLIENT_ID:      ${{ secrets.AZURE_CLIENT_ID || vars.AZURE_CLIENT_ID }}
  VM_ADMIN_PASSWORD:    ${{ secrets.VM_ADMIN_PASSWORD }}
  AZURE_LOCATION:       ${{ vars.AZURE_LOCATION || 'eastus2' }}
  AZURE_RESOURCE_GROUP: ${{ inputs.resource_group || secrets.AZURE_RESOURCE_GROUP || github.repository_owner }}

Two values deliberately have no default. The identity IDs must come from a secret or a variable (your instructor sets them on classroom forks), and a check step stops the run with a clear message if one is missing. And when VM_ADMIN_PASSWORD is empty, a later step generates a random password for that run and hides it with ::add-mask:: β€” so there is never a predictable default password to guess.

Read the last line right to left: the resource group defaults to the fork owner’s name (your pre-created group is named after your account), a repo secret overrides that, and a manual workflow input overrides both. That chain is why a pre-staged fork deploys on the first click β€” and why a self-hosted fork can point the very same workflow at its own subscription just by setting secrets.

Setting them (self-hosted β€” a set value always beats the fallback):

# Variable (readable, appears in logs)
gh variable set AZURE_PREFIX  --body "alice"
gh variable set AZURE_LOCATION --body "eastus2"

# Secret (write-only, masked in logs)
gh secret set AZURE_RESOURCE_GROUP  --body "<your-rg>"
gh secret set VM_ADMIN_PASSWORD     --body "S0me-Throwaway-Pass!"

List what you have

gh secret list    # shows names and timestamps (never values)
gh variable list  # shows names and values

On a classroom fork you should see the three AZURE_*_ID names your instructor set (as secrets or as variables), plus any password you chose yourself. On a self-hosted fork, the Setup-Oidc.ps1 script sets all secrets and variables for you automatically β€” this section explains what it does so you can manage them by hand if needed.


⌨️ Handy gh commands in this workshop

gh repo fork
gh repo clone <owner>/<repo>
gh secret set NAME     --body "value"
gh variable set NAME   --body "value"
gh secret list
gh variable list
gh workflow list
gh workflow run "Curriculum L1.1 - Core Deployment"
gh run list
gh run watch

πŸ”— Going further

  • GitHub Skills (interactive, free) β€” https://skills.github.com/
  • Understanding OIDC in Actions β€” https://docs.github.com/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect
  • Encrypted secrets β€” https://docs.github.com/actions/security-guides/using-secrets-in-github-actions
  • Environments and protection rules β€” https://docs.github.com/actions/deployment/targeting-different-environments/using-environments-for-deployment



GitHub feature spotlight Β· Status checks on a pull request

You just used it: this repo runs a check on every pull request that touches the instructor templates in scripts/admin/: it compiles them and previews what they would change, before anything can merge. Find it: the Actions tab, or the checks section at the bottom of any open pull request. admin-template-preview.yml is the whole thing. Beyond the lab: a status check plus a branch protection rule is how a team stops β€œit worked on my machine” from reaching main. The rule is enforced by the platform, not by people remembering. Docs β†’