/github-for-non-tech

How to automate tasks with GitHub Actions?

Discover how to automate tasks with GitHub Actions. Learn to set up a repo, create workflows, define triggers, and secure secrets with our step-by-step guide.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to automate tasks with GitHub Actions?

 

Step 1: Create a GitHub Repository

 

Before automating any tasks, you need a repository where your code and workflow files will live.

Follow these steps:

  • Go to GitHub’s New Repository page.
  • Enter a repository name, description (optional), and choose visibility (public or private).
  • Click Create repository.

 

Step 2: Enable GitHub Actions

 

All public repositories already have GitHub Actions enabled by default. Private repos do too, if your plan supports them.

  • In your repo, click the Actions tab.
  • GitHub may suggest starter workflows for common languages and platforms. You can choose one or start from scratch.

 

Step 3: Create a Workflow File

 

Workflows live in the .github/workflows/ folder of your repo. Let’s create a file named ci.yml.

On your local machine or via GitHub’s UI:

mkdir -p .github/workflows
cat > .github/workflows/ci.yml << 'EOF'
name: CI Pipeline
on: push
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Say Hello
        run: echo "Hello, GitHub Actions!"
EOF

 

Step 4: Define Event Triggers

 

Specify when the workflow should run under the on: key in your YAML.

  • push: triggers on every push to branches you specify.
  • pull\_request: runs on PR creation, update, or merge.
  • schedule: cron-based scheduling.
  • Combined triggers:
    on:
      push:
        branches: [ main, develop ]
      pull\_request:
        branches: [ main ]
      schedule:
        - cron: '0 0 _ _ \*'  # daily at midnight UTC
    

 

Step 5: Configure Jobs and Runners

 

A workflow can define multiple jobs that run in parallel or sequentially.

  • runs-on: specifies the VM image (e.g., ubuntu-latest, windows-latest).
  • needs: if Job B depends on Job A, use needs: [job-a].
  • strategy.matrix: run multiple configurations in parallel (e.g., Node versions).
    strategy:
      matrix:
        node-version: [12, 14, 16]
    steps:
    - uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
    ...
    

 

Step 6: Add Steps and Reusable Actions

 

Each job consists of ordered steps. Steps can be shell commands or pre-built actions.

  • Use actions/checkout@v3 to get your repo.
  • Use community or official actions, e.g., actions/setup-python@v4 or actions/cache@v3.
  • Run inline shell commands with run:.
  • Example:
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.9'
    - name: Install dependencies
        run: pip install -r requirements.txt
    - name: Run tests
        run: pytest
    

 

Step 7: Commit and Push Your Workflow

 

Once your workflow file is ready, commit and push to your repository.

git add .github/workflows/ci.yml
git commit -m "Add CI workflow"
git push origin main
  • On push, GitHub Actions will detect the new file and trigger your workflow.
  • You can watch progress in the Actions tab of your repo.

 

Step 8: Monitor and Debug Runs

 

Use GitHub’s UI to inspect each run.

  • Click a workflow run to see job and step logs.
  • Expand steps to view detailed output and error messages.
  • Re-run failed or successful workflows with the Re-run jobs button.

 

Step 9: Secure Secrets and Environment Variables

 

Don’t hardcode sensitive data. Store keys and tokens in GitHub Secrets.

  • Navigate to Settings → Secrets and variables → Actions.
  • Click New repository secret and add SECRET\_NAME.
  • Reference in your workflow:
    steps:
    - name: Use secret
        run: echo "Secret is ${{ secrets.SECRET\_NAME }}"
    
  • Environment variables: define under env: at workflow, job, or step level.

 

Step 10: Explore Advanced Features

 

GitHub Actions supports many advanced capabilities:

  • Matrix Builds for testing multiple OS/versions in parallel.
  • Caching package managers to speed up builds (actions/cache@v3).
  • Reusable Workflows by calling one workflow from another.
  • Artifacts to upload and download build outputs (@actions/upload-artifact).
  • Self-hosted Runners for custom hardware or environments.

 

By following these steps, you’ll have a solid foundation for automating tasks with GitHub Actions. Explore the official documentation to learn more and tailor workflows to your project’s needs.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022