This article covers installing Git and the GitHub CLI, connecting to GitHub, common workflows on Ubuntu, keeping tools updated, and troubleshooting. It assumes Ubuntu 20.04 or later; commands use sudo where needed.
Create .github/workflows/upd-automation.yml:
name: Remote Ubuntu UPD Automationon: schedule: - cron: '0 2 * * 3' # Every Wednesday at 2 AM workflow_dispatch: # Allow manual trigger
jobs: run-upd: runs-on: ubuntu-latest steps: - name: Checkout UPD script from repo uses: actions/checkout@v4
- name: Run UPD script on remote Ubuntu uses: appleboy/ssh-action@v1.0.0 with: host: $ secrets.UBUNTU_HOST username: $ secrets.UBUNTU_USER key: $ secrets.SSH_PRIVATE_KEY script: | cd /tmp git clone https://github.com/your-username/ubuntu-upd-scripts.git cd ubuntu-upd-scripts/scripts chmod +x upd-core.sh sudo ./upd-core.sh
Now, your Ubuntu server will be updated automatically every Wednesday at 2 AM – all orchestrated from GitHub.
ubuntu-upd-client.sh)Run this on each Ubuntu machine to check updates and report to GitHub.
#!/bin/bash # ubuntu-upd-client.sh # Reports pending updates to GitHub Issue or PRREPO="your-org/ubuntu-updates" GITHUB_TOKEN="your_personal_access_token" MACHINE_ID=$(hostname) github for ubuntu upd
5. Dashboard View – GitHub Project Board
Create a Project (Board) with columns:
- Pending Updates
- Approved / In Progress
- Completed / Failed
Add automation:
- New issue → Pending Updates
- Command
/upgrade→ Approved / In Progress- Issue closed → Completed
Create GitHub issue
curl -X POST
-H "Authorization: token $GITHUB_TOKEN"
-H "Accept: application/vnd.github.v3+json"
https://api.github.com/repos/$REPO/issues
-d ""title":"📦 Updates for $MACHINE_ID","body":$BODY,"labels":["updates-pending","$MACHINE_ID"]"
While GitHub Actions typically run on GitHub’s runners, you can use them to trigger updates on your own Ubuntu machines via SSH.
gh)While Git handles the code, the GitHub CLI (gh) allows you to interact with GitHub features (PRs, Issues, Actions) without leaving the terminal. The version in the default Ubuntu repositories is often outdated, so it is recommended to install it via the official repository.
A well-organized repo ensures clarity. Here’s a suggested structure:
ubuntu-upd-scripts/
├── README.md
├── LICENSE
├── scripts/
│ ├── upd-core.sh # Main update script
│ ├── upd-security.sh # Security updates only
│ ├── upd-reboot.sh # Update with reboot
│ └── rollback.sh # Rollback last update
├── configs/
│ ├── upd.conf # Configuration variables
│ └── packages-whitelist.txt
├── hooks/
│ ├── pre-upd.sh # Pre-update checks
│ └── post-upd.sh # Post-update actions
├── logs/
│ └── .gitkeep # Placeholder for log directory
└── .github/
└── workflows/
└── upd-automation.yml
sudo apt update
sudo apt upgrade gh