Cache Anbox Cloud images #506
This file contains hidden or 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@5a3ec84eff668545956fd18022155c47e93e2684 # v4 | |
| with: | |
| path: images | |
| key: anbox-images-amd64 |