Bar wrote:
I like that idea a lot. I wonder if there is a way to automate it.
There is, many projects do it.
google search
how to configure automated nightly builds in github
returns:
AI Overview
To configure automated nightly builds in GitHub, you primarily use GitHub
Actions and the schedule event with a cron expression. This process involves
creating a YAML workflow file that defines when the build should run and what
steps to execute.
Step 1: Create a GitHub Actions Workflow File
Navigate to your repository on GitHub.
Go to the Actions tab.
Click on New workflow.
Choose to set up a workflow yourself by clicking set up a workflow yourself (or
a similar link at the top of the suggested templates). This opens a new file
editor for a YAML file in the .github/workflows/ directory.
Name the file something descriptive, like nightly-build.yml
Step 2: Define the Schedule Trigger
In your YAML file, use the on:schedule: block with a cron expression to specify
the nightly frequency.
name: Deploy Nightly
on:
schedule:
# Run every night at 2 AM UTC
- cron: ‘0 2 * * *’
Allows manual triggering from the GitHub web interface
workflow_dispatch:
The cron: ‘0 2 * * *’ expression schedules the workflow to run at 2:00 AM
Coordinated Universal Time (UTC) every day. You can adjust the cron expression
to your preferred time and frequency.
Step 3: Define the Build Job
Below the on: block, define the jobs: section. This section outlines the steps
for your build process. The specific steps will depend on your project’s
language and requirements (e.g., Node.js, Python, Docker).
jobs:
nightly-build:
runs-on: ubuntu-latest # or windows-latest, macOS-latest, depending on your
needs
steps:
- name: Check out repository code
uses: actions/checkout@v4
# Add steps here to build your project (e.g., install dependencies,
compile, test)
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
# Add steps to upload the build as an artifact or release asset (optional
but recommended)
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: nightly-build-assets
path: ./dist # adjust ‘dist’ to your build output directory
Step 4: Commit and Monitor
Commit the new YAML file to your repository’s main branch.
The workflow will automatically run at the scheduled time. You can monitor the
progress and view logs in the Actions tab of your repository.
Optional: Create a Nightly Release
Many nightly build setups also create a “pre-release” on GitHub to easily access
the latest build artifacts. You can use a GitHub Marketplace action, such as
Deploy Nightly, to automate this part of the process.