GitHub Actions چیٹ شیٹ
قابل تلاش، قابل پرنٹ GitHub Actions حوالہ: ورک فلو ٹریگرز، جابز، سٹیپس، ایکسپریشنز، میٹرکس، کیشنگ اور دوبارہ استعمال ہونے والے ورک فلوز۔ مفت۔
Workflow skeleton & triggers
12.github/workflows/ci.yml
name: CI
on: push
on: { push: { branches: [main] } }
on: { push: { tags: ["v*"] } }
on: pull_request
on: { pull_request: { paths: ["src/**"] } }
on: { schedule: [{ cron: "0 6 * * 1" }] }
on: workflow_dispatch
workflow_dispatch: { inputs: { env: { type: choice, options: [dev, prod] } } }
on: { release: { types: [published] } }
on: workflow_call
Jobs & runners
12jobs: { build: { runs-on: ubuntu-latest } }
runs-on: [macos-latest / windows-latest]
runs-on: [self-hosted, linux, x64]
needs: build
needs: [lint, test]
if: github.ref == 'refs/heads/main'
container: node:22
services: { redis: { image: redis:7, ports: ["6379:6379"] } }
outputs: { sha: ${{ steps.vars.outputs.sha }} }
needs.build.outputs.sha
defaults: { run: { working-directory: app } }
strategy: { fail-fast: false }
Steps & popular actions
14- uses: actions/checkout@v4
- uses: actions/checkout@v4 with fetch-depth: 0
- uses: actions/setup-node@v4 with node-version: 22
- uses: actions/setup-python@v5 with python-version: "3.12"
- uses: shivammathur/setup-php@v2 with php-version: "8.3"
- run: npm ci && npm test
- run: | (multiline)
- name: Build
- id: vars
echo "sha=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
echo "PATH_EXTRA=/opt/bin" >> "$GITHUB_ENV"
- uses: actions/upload-artifact@v4
- uses: actions/download-artifact@v4
continue-on-error: true
Expressions & contexts
14${{ github.ref }}
${{ github.ref_name }}
${{ github.sha }}
${{ github.event_name }}
${{ github.actor }}
${{ github.repository }}
${{ github.event.pull_request.number }}
${{ secrets.API_KEY }}
${{ vars.SITE_URL }}
${{ env.NODE_ENV }}
${{ runner.os }} / ${{ runner.temp }}
${{ steps.vars.outputs.sha }}
contains(), startsWith(), format()
GITHUB_TOKEN
Conditionals & matrix
11if: success() / failure() / always()
if: cancelled()
if: github.event_name == 'push'
if: startsWith(github.ref, 'refs/tags/')
if: contains(github.event.head_commit.message, '[skip e2e]')
strategy: { matrix: { node: [20, 22] } }
matrix: { os: [ubuntu-latest, macos-latest], node: [20, 22] }
${{ matrix.node }}
matrix: { include: [{ os: ubuntu-latest, node: 23, experimental: true }] }
matrix: { exclude: [{ os: macos-latest, node: 20 }] }
max-parallel: 2
Caching & artifacts
11- uses: actions/cache@v4
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: | npm-
path: ~/.npm
setup-node@v4 with cache: npm
setup-python@v5 with cache: pip
upload-artifact@v4 with name/path
upload-artifact: retention-days: 5
download-artifact@v4 (no name)
if-no-files-found: error
Cache limit: 10 GB per repo
Environments & permissions
11permissions: { contents: read }
permissions: { contents: write, pull-requests: write }
permissions: { id-token: write }
environment: production
environment: { name: prod, url: https://app.example.com }
Environment protection rules
env: { NODE_ENV: production }
secrets.GITHUB_TOKEN
Settings > Secrets and variables > Actions
Org secrets with repo allowlists
pull_request_target: use with care
Reusable workflows & composite actions
11on: { workflow_call: { inputs: ..., secrets: ... } }
jobs: { ci: { uses: org/repo/.github/workflows/ci.yml@v1 } }
uses: ./.github/workflows/ci.yml
with: { node-version: 22 }
secrets: inherit
${{ inputs.node-version }}
action.yml with runs: { using: composite }
steps: - run: ... shell: bash
uses: ./.github/actions/setup
inputs/outputs in action.yml
Nesting limit: 4 levels of reusable calls
Concurrency & timeouts
9concurrency: { group: deploy, cancel-in-progress: true }
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
timeout-minutes: 15 (job level)
timeout-minutes: 5 (step level)
retry via nick-fields/retry@v3
jobs.<id>.strategy.max-parallel
if: always() on cleanup steps
Scheduled runs can be delayed/skipped
Common recipes
12on: push: tags: ["v*"] + softprops/action-gh-release@v2
on: push: paths: ["apps/api/**"]
dorny/paths-filter@v3
peaceiris/actions-gh-pages@v4
docker/build-push-action@v6
docker/login-action@v3 with ghcr.io
aws-actions/configure-aws-credentials@v4 (OIDC)
appleboy/ssh-action@v1
codecov/codecov-action@v4
github/codeql-action
dependabot.yml + auto-merge workflow
schedule + stale action
Debugging
12Secret ACTIONS_STEP_DEBUG = true
Secret ACTIONS_RUNNER_DEBUG = true
Re-run jobs > Enable debug logging
act
act -j build
act -s GITHUB_TOKEN=$(gh auth token)
echo "::debug::message"
echo "::error file=app.js,line=1::Oops"
echo "::group::Install" ... "::endgroup::"
$GITHUB_STEP_SUMMARY
mxschmitt/action-tmate@v3
cat "$GITHUB_EVENT_PATH"
gh CLI for Actions
13gh run list
gh run list --workflow ci.yml
gh run watch
gh run view 123456 --log
gh run view --log-failed
gh run rerun 123456 --failed
gh run cancel 123456
gh run download 123456
gh workflow list
gh workflow run ci.yml -f env=prod
gh workflow disable ci.yml
gh secret set API_KEY
gh cache list / gh cache delete
کوئی اندراج “:q” سے میل نہیں کھاتا۔
GitHub Actions چیٹ شیٹ کے بارے میں
یہ GitHub Actions چیٹ شیٹ ورک فلو YAML کو ایک قابل تلاش صفحے میں سمیٹتی ہے: ورک فلو کا ڈھانچہ اور ٹریگرز، جابز اور رنرز، سٹیپس اور مقبول ایکشنز، ایکسپریشنز اور کانٹیکسٹس، شرائط اور میٹرکس بلڈز، کیشنگ اور آرٹیفیکٹس، ماحول اور اجازتیں، دوبارہ استعمال ہونے والے ورک فلوز اور کمپوزٹ ایکشنز، کنکرنسی اور ٹائم آؤٹس، عام ترکیبیں، ڈیبگنگ، اور Actions کے لیے gh CLI کمانڈز۔
ورک فلو فائلیں زیادہ تر یاد رکھے ہوئے سنٹیکس پر مشتمل ہوتی ہیں (کون سا ٹریگر ٹیگ پر چلتا ہے، سیکرٹ کا حوالہ کیسے دیں، فورک پر سٹیپ چھوڑنے والا if ایکسپریشن، لاک فائل کے لیے کیش کی کا پیٹرن)، اس لیے ہر قطار ایک سطری وضاحت کے ساتھ YAML کا ٹکڑا دکھاتی ہے۔
شیٹ مفت اور کلائنٹ سائیڈ ہے: سرچ باکس سے قطاروں کو لائیو فلٹر کریں، چپکے رہنے والی فہرست مضامین سے حصوں کے درمیان کودیں، ایک کلک سے کوئی بھی ٹکڑا کاپی کریں اور میز کے حوالے کے طور پر صفحہ پرنٹ کریں۔
GitHub Actions چیٹ شیٹ استعمال کرنے کا طریقہ
- حصوں پر نظر ڈالیں، Workflow skeleton & triggers اور Jobs & runners سے لے کر gh CLI for Actions تک۔
- matrix، secrets یا cache جیسا کوئی کلیدی لفظ تلاش کریں تاکہ ہر قطار لائیو فلٹر ہو جائے۔
- اپنانے کے لیے تیار بلڈ، ٹیسٹ یا ڈیپلائے جاب کے لیے Common recipes پر جائیں۔
- YAML کے ٹکڑے کو اپنی ورک فلو فائل میں کاپی کرنے کے لیے اس پر یا اس کے کاپی آئیکن پر کلک کریں۔
- آف لائن GitHub Actions حوالے کے لیے شیٹ پرنٹ کریں۔