Source: examples/github_actions
Example: Github Actions + SkyPilot#
Run a SkyPilot Task with Github Actions
Define a repository secret#
You may need to inject sensitive variables (such as authentication credentials, etc.) into the github action. Follow ths github tutorial to add a repository secret.
In this example, create a repository secret named SKYPILOT_API_SERVER_ENDPOINT
that stores the remote API server endpoint.
Define a workflow YAML#
Given a simple repository with following directory tree:
.
├── .git
│ ...
├── .github
│ └── workflows
│ └── run-sky.yaml
├── sample_job.yaml
└── skypilot_config.yaml
When a PR is submitted against main
branch of this repo or a commit is merged the main
branch, run_sky.yaml
launches sample_job.yaml
using skypilot_config.yaml
as config.
Included files#
run_sky.yaml
name: Run SkyPilot Task
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main
merge_group:
jobs:
run-skypilot-task:
strategy:
matrix:
python-version: ["3.10"]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
uv venv --seed ~/sky
source ~/sky/bin/activate
uv pip install --prerelease=allow "azure-cli>=2.65.0"
uv pip install 'omegaconf>=2.4.0dev3' 'skypilot[all]'
- name: Run SkyPilot job
run: |
source ~/sky/bin/activate
sky api login --endpoint $SKYPILOT_API_SERVER_ENDPOINT
SKYPILOT_PROJECT_CONFIG=skypilot_config.yaml sky jobs launch sample_job.yaml -y
env:
SKYPILOT_API_SERVER_ENDPOINT: ${{ secrets.SKYPILOT_API_SERVER_ENDPOINT }}