This file contains hands-on exercises to help you master GitHub Actions. Complete these tasks to solidify your understanding!
Objective: Understand how workflows execute
Steps:
- Go to your repository
- Click the "Actions" tab
- Find the "Hello World Workflow"
- Click "Run workflow" → "Run workflow" button
- Watch it execute in real-time
- Check the logs to see all the outputs
What You'll Learn:
- How to trigger workflows manually
- How to read workflow logs
- Understanding GitHub context variables
Completion: ✅ Expand the workflow job and verify you can see all the echo outputs
Objective: Learn when workflows are triggered
Steps:
- Edit
.github/workflows/hello-world.yml - Make a small change (add a comment)
- Commit and push to
main - Go to Actions tab and verify the workflow ran automatically
- Check the workflow was triggered by
pushevent
What You'll Learn:
- How push events trigger workflows
- The difference between manual and automatic triggers
Completion: ✅ The workflow should run automatically when you push
Objective: Run the sample app and tests locally
Steps:
cd sample-app
npm install
npm test
npm start- Visit
http://localhost:3000in your browser - Test different API endpoints
What You'll Learn:
- How the sample application works
- Running tests locally
- Testing API endpoints
Completion: ✅ All tests pass and the server starts without errors
Objective: Build your own GitHub Actions workflow
Steps:
- Create
.github/workflows/custom.yml - Add a workflow that:
- Triggers on push to
developbranch - Sets up Node.js 18
- Runs:
npm install && npm testin thesample-appdirectory
- Triggers on push to
- Commit and push to the
developbranch - Verify the workflow runs in Actions tab
Example to get started:
name: Custom Workflow
on:
push:
branches: [develop]
jobs:
custom-job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Add more steps...What You'll Learn:
- Creating workflows from scratch
- Working with different branches
- Configuring workflows for specific directories
Completion: ✅ Your custom workflow runs successfully on the develop branch
Objective: Use environment variables in workflows
Steps:
- Edit
.github/workflows/build-test.yml - Add environment variables at the job level:
env: NODE_ENV: test LOG_LEVEL: debug
- Add a step to print these variables:
- name: Print environment run: | echo "Environment: ${{ env.NODE_ENV }}" echo "Log Level: ${{ env.LOG_LEVEL }}"
- Push the changes and verify the workflow logs show the values
What You'll Learn:
- Setting environment variables in workflows
- Accessing environment variables in steps
- Job-level vs global environment variables
Completion: ✅ Environment variables are printed in the workflow logs
Objective: Practice working with secrets (without exposing real credentials)
Steps:
- Create a test secret:
- Settings → Secrets and variables → Actions
- New secret:
TEST_SECRET=my-secret-value
- Edit
.github/workflows/hello-world.yml - Add a step:
- name: Access secret run: echo "Secret length: ${#{{ secrets.TEST_SECRET }}}"
- Push and verify in logs (secret won't be displayed)
What You'll Learn:
- Creating and storing secrets
- Using secrets in workflows
- How GitHub masks secrets in logs
Completion: ✅ Workflow runs successfully and secret is masked in logs
Objective: Test across multiple configurations
Steps:
- Look at
.github/workflows/build-test.ymlwhich already has matrix configuration - Understand how it tests multiple Node versions
- Modify the matrix to test 3 different Node versions:
strategy: matrix: node-version: [16.x, 18.x, 20.x]
- Push and verify it creates 3 parallel job runs
What You'll Learn:
- Using matrix strategy for multiple configurations
- Parallel job execution
- Testing compatibility across versions
Completion: ✅ Workflow runs 3 jobs in parallel for different Node versions
Objective: Pass data between jobs using artifacts
Steps:
- Edit
.github/workflows/build-test.yml - After the build step, add:
- name: Create artifact run: echo "Build output" > output.txt - name: Upload artifact uses: actions/upload-artifact@v3 with: name: build-output path: output.txt
- Add a new job that depends on this job and downloads the artifact
- Push and verify artifacts in the Actions UI
What You'll Learn:
- Uploading artifacts
- Downloading artifacts
- Job dependencies
- Artifact persistence
Completion: ✅ Artifact is uploaded and can be downloaded from Actions UI
Objective: Run steps conditionally based on events/conditions
Steps:
- Create
.github/workflows/conditional.yml - Add workflow with steps that only run on
mainbranch:- name: Deploy (main only) if: github.ref == 'refs/heads/main' run: echo "Deploying to production..."
- Test by pushing to
develop- deployment step should be skipped - Push to
main- deployment step should run
What You'll Learn:
- Using
ifconditions in workflows - GitHub context variables
- Conditional job/step execution
Completion: ✅ Steps execute/skip based on branch conditions
Objective: Practice contribution workflow with templates
Steps:
- Fork this repository (if it's on GitHub)
- Create a new branch:
git checkout -b feature/my-feature - Make a small change to the sample app
- Commit and push:
git push origin feature/my-feature - Create a Pull Request from your fork
- Use the PR template to describe your changes
- In Issues tab, create an issue using one of the templates
What You'll Learn:
- GitHub workflow (fork, branch, PR)
- Using contribution templates
- Community participation
Completion: ✅ PR and Issue created with proper template format
Objective: Deploy the sample app to Azure App Service
Requirements:
- Azure account (free tier available)
- Create an App Service
- Set up Azure credentials as GitHub secret
- Deploy using
.github/workflows/deploy-azure-app-service.yml
Steps:
- Create Azure App Service
- Create service principal for authentication
- Add
AZURE_CREDENTIALSsecret - Push to main branch
- Monitor deployment in Actions tab
- Verify app is running on Azure
What You'll Learn:
- Azure App Service deployment
- GitHub Secrets for production credentials
- Multi-stage deployments (staging → production)
Completion: ✅ App is deployed and accessible at Azure URL
Objective: Generate and track code coverage
Steps:
- Modify
.github/workflows/build-test.yml - Add coverage reporting:
- name: Upload coverage uses: codecov/codecov-action@v3 with: files: ./sample-app/coverage/coverage-final.json
- Push and verify coverage report is uploaded
- Check Codecov dashboard
What You'll Learn:
- Code coverage reporting
- Integration with external services
- Quality metrics tracking
Completion: ✅ Coverage reports are generated and uploaded
Objective: Build your own reusable GitHub Action
Steps:
- Create
.github/actions/hello-world-action/action.yml - Define inputs and outputs
- Add JavaScript or composite action steps
- Use it in a workflow
- Document how to use it
What You'll Learn:
- Custom action creation
- Action structure and configuration
- Reusable workflow components
- Sharing actions with community
Completion: ✅ Custom action works and can be used in workflows
Track your progress:
- Beginner (1-3): Hello World, Triggers, Local Testing
- Intermediate (4-7): Custom Workflow, Env Vars, Secrets, Matrix
- Advanced (8-10): Artifacts, Conditionals, PR/Issues
- Challenge: Azure Deployment, Coverage, Custom Action
After completing these tasks:
- Read the Documentation: Review all files in the
docs/folder - Explore Workflows: Understand how each example workflow works
- Modify Workflows: Change triggers, steps, and conditions
- Experiment: Create your own workflows for your projects
- Share: Help others and contribute improvements
If you're stuck:
- Check the documentation
- Review the example workflows in
.github/workflows/ - Create an issue using the question template
- Check GitHub Actions logs for error messages
🎉 Congratulations on starting your GitHub Actions learning journey!
Each task you complete makes you more proficient with automation and CI/CD. Keep practicing and you'll become a GitHub Actions expert!
Happy Learning! 🚀