Skip to content

update-gcp-catalog #2181

update-gcp-catalog

update-gcp-catalog #2181

name: "update-gcp-catalog"
on:
schedule:
- cron: '00 */7 * * *' # Every 7 hours (GCP guarantees the price changes up to once a month, but different VMs may change at different times)
# The frequency can be tuned for the trade-off between
# freshness of the price and github action cost/user downloading
# overhead of the update.
# _PULL_FREQUENCY_HOURS in `gcp_catalog.py` need to be updated
# accordingly, if this is changed.
workflow_dispatch:
jobs:
update_gcp_catalog:
runs-on: ubuntu-latest
steps:
- name: Clone SkyPilot repo
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: skypilot-org/skypilot
path: sky
- name: Clone Catalog repo
uses: actions/checkout@v4
with:
fetch-depth: 0
path: catalogs
token: ${{ secrets.GH_ACTION_PAT }}
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
python-version: "3.10"
- name: Install dependencies
run: |
uv venv --seed ~/catalogs-venv
source ~/catalogs-venv/bin/activate
cd sky
uv pip install ".[gcp]"
cd ~
- id: 'auth'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}'
- name: Run fetch_gcp
id: fetch_catalogs
run: |
source ~/catalogs-venv/bin/activate
versions=$(cat catalogs/.metadata.yml | yq -r '.version_commit | keys[]')
for version in $versions; do
commit_hash=$(cat catalogs/.metadata.yml | yq -r ".version_commit.$version")
cd sky
echo "> Fetching catalog schema version $version with SkyPilot commit hash $commit_hash ..."
if [ "$commit_hash" == "latest" ]; then
commit_hash=$(git rev-parse origin/master)
fi
echo "> Checking out SkyPilot to commit hash $commit_hash ..."
git checkout $commit_hash
uv pip install ".[gcp]"
cd -
echo "> Creating catalog directory ..."
mkdir -p catalogs/catalogs/$version
cd catalogs/catalogs/$version
echo "> Fetching GCP catalog ..."
python -u -m sky.clouds.service_catalog.data_fetchers.fetch_gcp --all-regions --single-threaded
cd -
done
env:
GCP_SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
- name: Commit catalog
run: |
versions=$(cat catalogs/.metadata.yml | yq -r '.version_commit | keys[]')
cd catalogs
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m"[Bot] Update GCP catalog $versions (scheduled at $(date))" || { echo "No changes to commit" && exit 0; }
git fetch origin
git rebase origin/master
git push