Post

How to test GitHub Actions

Unleash the power of targeted testing 🎯 and streamlined development with branch-specific workflows in GitHub Actions! This guide takes you step-by-step πŸšΆβ€β™‚οΈ through the process of setting up your own custom workflow, ensuring your tests only run on relevant branches and keeping your workflow clean and efficient. ✨

Committing a test.yml to your main branch can trigger other actions on the push event!

1. Create new branch

Create a new branch called action-test from your main branch

1
git checkout -b action-test-branch

2. Add new yml file

1
touch .github/workflows/test.yml

3. Add your trigger

Edit the trigger in yml file to work on push event on action-test-branch

1
2
3
4
5
6
7
8
9
10
11
12
13
14
name: "My Test Workflow"

on:
  workflow_dispatch:
  push:
    branches:
      - action-test-branch

jobs:
  my-job:
    runs-on: ubuntu-latest
    steps:
      - name: my-step
        run: echo "Hello World!"

4. Commit and push

1
2
git add ".github/workflows/test.yml"
git commit -m "Added test workflow!"

5. Done

GitHub.com > Actions will show only the test.yml workflow is running without affecting other actions on main branch

This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.