GitHub Actions
GitHub Actions Core Concepts
Create and Run Workflow
In this guide, you’ll learn how to set up a simple GitHub Actions workflow that runs on every push. We’ll walk through creating a new repository, editing in the browser-based editor, installing the GitHub Actions extension, and troubleshooting a common error.
1. Initialize a New Public Repository
- Navigate to GitHub and click New to create a repository.
- Name it
actions-1
, set visibility to Public, and Initialize with a README. - Click Create repository.
2. Edit in the GitHub.dev Browser IDE
- In your browser’s address bar, replace
github.com
withgithub.dev
and press Enter. - Wait a few seconds for the VS Code–powered editor to load.
- You can now edit, commit, and push files directly from the web IDE.
Note
Using GitHub.dev gives you instant access to a VS Code–like environment without any local setup.
3. Install the GitHub Actions Extension
For syntax highlighting, validation, and IntelliSense in YAML workflows:
- Open the Extensions tab in the sidebar.
- Search for GitHub Actions.
- Click Install on the GitHub Actions extension.
4. Create the Workflow File
- In the file explorer, create a new folder:
.github/workflows/
. - Inside it, add
firstexample.yml
.
- Paste the following YAML:
name: My First Workflow
on: push
jobs:
first_job:
runs-on: ubuntu-latest
steps:
- name: Welcome message
run: echo "My first GitHub Actions Job"
- name: List files
run: ls
- name: Read file
run: cat README.md
Warning
YAML is indentation-sensitive. Ensure you use spaces (not tabs) and proper nesting to avoid validation errors like “mapping or sequence required.”
- Commit and push your changes:
git add .github/workflows/firstexample.yml
git commit -m "first workflow"
git push
5. Observe the Workflow Run
Since the workflow triggers on push
, it runs immediately. Switch back to GitHub.com and click the Actions tab.
Refresh to see My First Workflow in the list.
Click the run to inspect:
6. Troubleshoot: Missing Checkout Step
You’ll see this error in the logs:
Run echo "My first GitHub Actions Job"
Run ls
Run cat README.md
cat: README.md: No such file or directory
Error: Process completed with exit code 1
By default, Actions runners don’t fetch your code. Add the checkout action before accessing files:
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Welcome message
run: echo "My first GitHub Actions Job"
# other steps...
Workflow Components Overview
Keyword | Purpose | Example |
---|---|---|
name | Friendly workflow name | My First Workflow |
on | Event that triggers the workflow | push , pull_request |
jobs | Collection of tasks | first_job |
runs-on | Defines the runner environment | ubuntu-latest |
steps | Ordered list of actions and commands | actions/checkout@v3 , run |
Links and References
Watch Video
Watch video content