الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

act

Run GitHub Actions workflows on your own machine in Docker — test a pipeline before you push.

المستوى
أداة DevOps
المجموعة
Git و CI/CD
يحتاج root
لا
الحزمة
act

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

Changing a workflow and pushing again and again to see if it works is slow. act reads .github/workflows/*.yml and runs the jobs locally in Docker containers that look like the GitHub runners. You see errors in seconds.

Not everything is the same as on GitHub (for example OIDC to the cloud and some services), but builds, tests, linters and scripts work well.

طريقة الكتابة

act [EVENT] [OPTIONS]

الخيارات 13

الأكثر استخدامًا

Options

EVENT
The event to simulate: push (default), pull_request, workflow_dispatch …
-j, --job NAME
Run only this job.
-l, --list
List the jobs and workflows.
-W, --workflows PATH
Use this workflow file or folder.
-n, --dryrun
Show what would run.
-s NAME=VALUE / --secret-file FILE
Give secrets.
--var NAME=VALUE / --var-file FILE
Give repository variables.
-e, --eventpath FILE
JSON file with the event payload.
-P ubuntu-latest=IMAGE
Choose the runner image.
--matrix KEY:VALUE
Run only one matrix entry.
--container-architecture linux/amd64
Needed on Apple Silicon for some images.
-v
Verbose output.
--input NAME=VALUE
Inputs for workflow_dispatch.

أمثلة 11

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 1List the jobs

    act -l
  2. 2Run the push workflows

    act
  3. 3Run one job of a pull request workflow

    act pull_request -j test
  4. 4Give a secret

    act -s GITHUB_TOKEN="$(gh auth token)"
  5. 5Secrets from a file (never commit it)

    cat .secrets
    NPM_TOKEN=xxxx
    act --secret-file .secrets
  6. 6Dry run

    act -n
  7. 7A bigger runner image (more tools inside)

    act -P ubuntu-latest=catthehacker/ubuntu:full-latest
  8. 8One matrix entry only

    act -j test --matrix node:22
  9. 9A manual workflow with inputs

    act workflow_dispatch --input environment=staging
  10. 10A custom event payload (for example a tag push)

    cat event.json
    { "ref": "refs/tags/v1.4.0" }
    act push -e event.json
  11. 11On a Mac with Apple Silicon

    act --container-architecture linux/amd64

انتبه

  • Add .secrets and .vars to .gitignore.
  • Steps with if: ${{ !env.ACT }} are a way to skip things that only work on GitHub.
  • The default small image misses many tools; jobs that pass locally can still fail on GitHub (and the other way).

الملفات

.actrc
Default options (for example the runner images).
.secrets / .vars
Local secrets and variables.

رموز الخروج

0All jobs passed.
1A job failed.