BM: Baca dalam Bahasa Melayu
World 7: Robots: Actions & CI/CD
Inside a workflow file
You will learn: the parts of a workflow file, and how to write one.
The problem
This file is a workflow: A YAML file in .github/workflows/ that tells the robot when and what to run.: a to-do list for a robot. It is written in YAML: A simple text format made of keys, colons and spaces. Workflows use it.. Looks scary? Read it as three parts: when, where, what.
Watch
Tap the line that says when the robot wakes up.
0 of 1 found
When: on: names the trigger (event): What wakes a workflow up, like a push, a pull request or a clock.. It says when the workflow runs. Here, on every push.
Watch
Where: under jobs: sits a job: A group of steps that runs on one fresh computer., a group of steps on one computer. What does runs-on: ubuntu-latest ask for?
Pick one answer.
Watch
What: a job has step: One task in a job: a command (run) or a ready-made action (uses).. They run in order, top to bottom. uses: borrows a ready-made action. run: types a command.
Drag a card into a box. Or tap the card, then tap the box.
Try it
Your turn. Build a workflow that tests every push.
Tap blocks to add them. Put them in order.
Blocks
Your workflow
Tap a block above to start.
Workflow file .github/workflows/
name: CI
What runs
Nothing to run yet.
Hint
When, then where, then what: trigger, job, steps.Predict
You move run: npm test above the checkout step. What happens?
Pick one answer.
Try it
A workflow is just a file in your repo. Save it with Git, like any other file.
- Empty
- 3 save points
- Ignore log files
- Add day 1 page
- Add README
Hint
Typegit add .github, then git commit -m "Add CI workflow".You did it!
You can now read and write a workflow file.
Go deeper (optional)
Make it real (optional). Open your diary repo on GitHub. In its Actions tab, pick a simple starter workflow and commit it. Wait a minute, then check here.
Check it on GitHub
- A workflow ran in your diary repoNot checked yet
Bahasa Melayu
Fail ini ialah workflow (aliran kerja): senarai tugas untuk robot. Ia ditulis dalam YAML. Nampak menakutkan? Baca sebagai tiga bahagian: bila, di mana, apa.
Bila: on: menamakan trigger (pencetus). Ia beritahu bila workflow berjalan. Di sini, pada setiap push.
Di mana: bawah jobs: ada satu job, iaitu kumpulan langkah pada satu komputer. Apa yang runs-on: ubuntu-latest minta?
Apa: job ada steps (langkah). Ia berjalan ikut urutan, atas ke bawah. uses: pinjam action siap pakai. run: taip satu arahan.
Giliran anda. Bina workflow yang uji setiap push.
Anda alihkan run: npm test ke atas langkah checkout. Apa jadi?
Workflow hanyalah fail dalam repo anda. Simpan dengan Git, macam fail lain.
git add .github, kemudian git commit -m "Add CI workflow".Kini anda boleh baca dan tulis fail workflow.
You finished this before. Practice is always welcome!
Official docs: Understanding GitHub Actions · Workflow syntax
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?