Key idea
GitHub Actions runs jobs for you when something happens in a repository, such as a push. That's where the checks on a pull request come from. ComputeSphere reads your code separately, through a GitHub App you install with access to only the repositories you choose.
Read a workflow
A workflow is a YAML file in .github/workflows/. This one runs the tests on every push to main and on every pull request:
name: Test
on:
push:
branches: [main]
pull_request:
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 test
Read it top to bottom:
on:is when it runs: a push tomain, or any pull request.jobs:holds one job,test.runs-on:asks for a fresh Linux machine from GitHub, called a runner.steps:run in order.uses:runs a ready-made action: here, fetch the code, then install Node 20.run:runs a shell command.
If npm test fails, the job goes red, and so does the check on the pull request. With Require status checks to pass before merging on main (lesson 2.7.2), a red job blocks the merge.
Every run is listed in the repository's Actions tab, with the log of each step.
Connecting GitHub to ComputeSphere
GitHub is the Git provider these paths teach, and the one to use with ComputeSphere today. ComputeSphere needs to read your repository to build it, and gets that access through the ComputeSphere GitHub App, never your password:
- In the console, open your account settings, go to Connections and choose Add connection, then Connect next to GitHub.
- In the GitHub window, choose your account or organization, then Only select repositories, and pick the ones you'll deploy.
- Back in ComputeSphere, choose the repository and the branch to build from.
You can remove a repository, or the whole app, from GitHub's settings at any time. Lesson 5.3.1, Connecting GitHub, walks through it when you first deploy from source.
When does a build happen?
You start a build yourself, from the console or from csph. In the console, open the service, choose Redeploy and keep Build & deploy selected: ComputeSphere builds the latest commit on your branch. A push on its own doesn't update your app.
To deploy from a workflow instead, a job signs in to ComputeSphere with a token kept in GitHub's secrets and runs the deploy for you. Lesson 5.8.4, GitHub Actions: setup-csph and the deploy action, shows how.
Check yourself