GitHub Actions CI/CD Quickstart & Practical Workflows
Continuous Integration and Continuous Deployment (CI/CD) form the backbone of modern automated software engineering.
GitHub Actions is a native automation suite built directly into GitHub. Without provisioning separate Jenkins runners or build servers, a straightforward YAML configuration in your repository automates unit tests, code analysis, container image builds, and binary releases whenever you push code, open pull requests, or publish release tags.
This guide breaks down core Actions concepts and walks through two real-world workflow implementations.
1. Core Architecture of GitHub Actions
Every GitHub Actions pipeline comprises five foundational components:
[Event (Trigger)]
└─ Examples: Push to main branch, Pull Request opened, Release published
│
▼
[Workflow]
└─ Automation pipeline defined in .github/workflows/*.yml
│
▼
[Job]
└─ A set of steps executing on a runner; multiple jobs run concurrently by default
│
▼
[Step]
└─ Atomic task within a job (executes shell commands or calls third-party Actions)
│
▼
[Runner]
└─ Virtual machine or container environment (ubuntu-latest, windows-latest, macos-latest)
Workflow configuration files reside under .github/workflows/ in the root of your repository.
2. Practical Workflow 1: Frontend / Node.js Automated Testing & Build
This workflow triggers on pushes and pull requests targeting the main branch, installing dependencies, executing linting rules, running tests, and verifying compilation.
Create .github/workflows/ci.yml:
name: Continuous Integration
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run lint and tests
run: |
npm run lint --if-present
npm test --if-present
- name: Build project
run: npm run build
Once committed to GitHub, inspect execution logs and real-time statuses under the repository Actions tab.
3. Practical Workflow 2: Automated Cross-Platform Release Packaging on Git Tags
When you publish a new version tag (e.g. v1.0.0), this workflow compiles binaries, packages archives, and creates a formal GitHub Release with downloadable assets attached.
Create .github/workflows/release.yml:
name: Publish Release
on:
push:
tags:
- "v*"
jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: Build binary
run: |
mkdir -p dist
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o dist/myapp-linux-amd64 .
tar -czvf dist/myapp-${{ github.ref_name }}-linux-amd64.tar.gz -C dist myapp-linux-amd64
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*.tar.gz
generate_release_notes: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Triggering this automated release pipeline requires just three Git commands:
git tag -a v1.0.0 -m "Release version 1.0.0"
git push origin v1.0.0
Within minutes, your GitHub Releases page provides compiled binary bundles ready for worldwide distribution.
4. Security & Best Practices: GitHub Secrets
In production pipelines, credentials such as Docker Hub access tokens, SSH private keys, or API tokens must be safeguarded. Never commit sensitive keys in plain text to your repository!
Configuring Repository Secrets
- Navigate to repository Settings -> Secrets and variables -> Actions.
- Click New repository secret.
- Name your variable (e.g.
DOCKERHUB_TOKEN) and enter the secret value. - Reference it securely within workflow files:
GitHub Actions automatically redacts matching secret values in log output, preventing credential leakage.- name: Log in to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }}
5. Deployment Acceleration: Integrating with GH-Proxy
When automated deployment scripts running on production edge servers need to fetch newly published GitHub Releases or pull container images, cross-region network bottlenecks can stall deployments.
Integrating GH-Proxy into deployment scripts ensures fast, resilient downloads:
# Automated deployment script with GH-Proxy acceleration
VERSION="v1.0.0"
ASSET_NAME="myapp-${VERSION}-linux-amd64.tar.gz"
curl -L -O "https://gh-proxy.org/https://github.com/your-username/your-repo/releases/download/${VERSION}/${ASSET_NAME}"
tar -zxvf "${ASSET_NAME}"
This guarantees fast delivery, high uptime, and zero script timeouts during production deployments.