In a GitHub repository, there is sometimes a folder called .github, and inside it, there is a workflows folder containing .yml files.
This is a configuration file for GitHub Actions, which is GitHub's automation mechanism.
By simply placing a file in this folder, you can enable things like "automatically test when code is pushed" or "automatically run a script every morning at 9:00."
In this article, I will introduce how .github/workflows works and how to write your first one.
What is .github/workflows?

.github/workflows is a folder for storing GitHub Actions "workflows" (procedures that run automatically).
When you place a .yml file here and push it to GitHub, GitHub reads the contents and...
When (when code is pushed, every morning at 9:00, when a button is pressed...)
What (testing, building, running scripts...)
It automatically executes these on GitHub's servers. You don't need to keep your own computer turned on.
Common use cases
Automated testing: Runs tests every time code is pushed and notifies you if something is broken
Automated deployment: Automatically publishes the site when pushed to the main branch
Scheduled execution: Fetches data and updates files every morning
Checks: Checks for coding style or accidentally included secret information
Your first one: Automated testing when code is pushed
Create a file named .github/workflows/test.yml and write the following.
name: テスト
on:
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm testIt means the following, in order from the top.
name: The name of the workflow (displayed on the GitHub screen)
on: When to run it. Here, it runs when pushed to the main branch
jobs: A collection of tasks to perform
runs-on: What kind of computer to run it on (here, Linux Ubuntu)
steps: The actual procedure. Executed in order from top to bottom
- actions/checkout: Fetches the repository code
- actions/setup-node: Prepares Node.js
- npm ci → npm test: Installs packages and runs tests
uses: means using components (actions) created by others, and run: means executing a command.
To run it automatically every morning
You can make it run periodically just by changing the on section.
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:schedule's cron: '0 0 * * *' means "0:00 every day". The time is UTC (Coordinated Universal Time), not Japan Standard Time, so it will be 9:00 AM Japan time
workflow_dispatch: A "Run workflow" button appears on the GitHub screen, allowing manual execution
Note that it may not run exactly at the set time and may be delayed depending on system load.
Put API keys in "Secrets"
When using an API key in a workflow, do not write it directly in the file; register it in GitHub's Secrets.
Go to the repository's "Settings" → "Secrets and variables" → "Actions"
Register the name (e.g., API_KEY) and value using "New repository secret"
You can read it from the workflow like this.
- run: node fetch.js
env:
API_KEY: $ secrets.API_KEY Even if displayed in the logs, the values of Secrets are automatically masked.
How to view results
Open the "Actions" tab in the repository to see the workflow execution history.
Green check: Success
Red X: Failure (click to see which step stopped and the error details)
What about the cost?
For public repositories, you can use standard GitHub servers for free. For private repositories, there is a monthly free usage allowance depending on your plan, and you will be charged if you exceed it. Please check the GitHub pricing page for the latest terms.
Differences from GAS triggers
Google Apps Script (GAS) also has triggers like "run every morning at 9 AM".
GAS triggers: Easier if you are working with Google services (Spreadsheets, Gmail, etc.)
GitHub Actions: Stronger for code-related automation, such as Node.js or Python scripts, testing, and site deployment
A common strength of both is that they run without needing to keep your own computer turned on.
Summary
.github/workflows is the folder where you place GitHub Actions automation steps
Write "when" in "on" and "what" in "steps"
For periodic execution, use "schedule" with "cron". Be careful with UTC time
Put API keys in Secrets and read them using $ secrets.NAME
---
The basics of how to write a workflow in "YAML" are explained here.
https://note.com/masuyohasiri/n/nb33674a8cb5e
An explanation of ".env" to avoid writing API keys in your code can be found here.
https://note.com/masuyohasiri/n/n93f576e25de4
I have summarized how to manage GAS on GitHub for absolute beginners.
https://note.com/masuyohasiri/n/n5c820a59ef63