Cache Anbox Cloud images #108
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cache Anbox Cloud images | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 10 * * *' | |
jobs: | |
cache-images: | |
name: Cache Anbox Cloud images | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Attach to Ubuntu Pro | |
run: | | |
sudo pro attach ${{ secrets.UBUNTU_PRO_TOKEN }} | |
sudo pro enable anbox-cloud --access-only | |
- name: Download images | |
run: | | |
image_server_auth="bearer:$(sudo cat /var/lib/ubuntu-advantage/private/machine-token.json | jq -r '.resourceTokens[] | select(.type=="anbox-images").token')" | |
image_server_url=https://"$image_server_auth"@images.anbox-cloud.io/stable | |
mkdir images | |
image_name=jammy:android13:amd64 | |
item_type=image | |
image_path="$(curl -s "$image_server_url"/streams/v1/images.json | \ | |
jq -r "last(.products.\"$image_name\".versions[] | select(.items.\"${item_type}\" != null)).items.\"${item_type}\".path")" | |
image_url="$image_server_url"/"$image_path" | |
curl -s "$image_url" -o images/android13.tar.xz | |
- name: Cache all images | |
uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4 | |
with: | |
path: images | |
key: anbox-images-amd64 |