Skip to content

schedule

schedule #148

Workflow file for this run

name: schedule
on:
push:
branches:
- '**'
tags-ignore:
- '**'
pull_request:
branches:
- '**'
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
archive:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- arch: aarch64
target: aosp_arm64
- arch: x86_64
target: aosp_x86_64
- arch: riscv64
target: aosp_cf_riscv64_phone
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
if: contains(matrix.target, '_cf_')
run: |
sudo apt-get update
sudo apt-get install -y linux-modules-extra-$(uname -r) erofs-utils erofsfuse
sudo modprobe erofs
- name: Install cuttlefish
if: contains(matrix.target, '_cf_')
run: |
ID=$(curl -fsSL https://ci.android.com/builds/branches/aosp-main/status.json | yq '.targets[] | select(.name == "aosp_cf_x86_64_phone-trunk_staging-userdebug") | .last_known_good_build')
ARTIFACT_URL=$(node <<EOF
$(curl -fsSL "https://ci.android.com/builds/submitted/$ID/aosp_cf_x86_64_phone-trunk_staging-userdebug/latest/cvd-host_package.tar.gz" | grep 'var JSVariables = ')
console.log(JSVariables['artifactUrl'])
EOF
)
sudo mkdir /opt/android-cuttlefish
curl -fsSL "$ARTIFACT_URL" | sudo tar -xzC /opt/android-cuttlefish
echo /opt/android-cuttlefish/bin | tee -a "$GITHUB_PATH"
- name: Download Image
run: |
ID=$(curl -fsSL https://ci.android.com/builds/branches/aosp-main/status.json | yq '.targets[] | select(.name == "${{ matrix.target }}-trunk_staging-userdebug") | .last_known_good_build')
ARTIFACT_URL=$(node <<EOF
$(curl -fsSL "https://ci.android.com/builds/submitted/$ID/${{ matrix.target }}-trunk_staging-userdebug/latest/${{ matrix.target }}-img-$ID.zip" | grep 'var JSVariables = ')
console.log(JSVariables['artifactUrl'])
EOF
)
curl -fsSLo img.zip "$ARTIFACT_URL"
unzip img.zip
- name: Mount system.img
run: |
mkdir SYSTEM
if test -f super.img; then
simg2img super.img unsparsed.img
lpunpack unsparsed.img
if [ "$(blkid -o value -s TYPE system_a.img)" = "erofs" ]; then
sudo erofsfuse -o allow_other system_a.img SYSTEM
else
sudo mount -o loop,ro system_a.img SYSTEM
fi
else
sudo mount -o loop,ro system.img SYSTEM
fi
- name: Mount com.android.runtime.apex
run: |
SYSTEM_EXT=SYSTEM/system_ext
if test -L $SYSTEM_EXT; then
SYSTEM_EXT=SYSTEM/system/system_ext
fi
if ! test -d $SYSTEM_EXT/apex/com.android.runtime; then
unzip SYSTEM/system/apex/com.android.runtime.apex apex_payload.img
sudo mount -t tmpfs tmpfs $SYSTEM_EXT
mkdir -p $SYSTEM_EXT/apex/com.android.runtime
sudo mount -o loop,ro apex_payload.img $SYSTEM_EXT/apex/com.android.runtime
fi
- name: List Contents
run: |
cd SYSTEM
sudo find . -ls
- name: Archive
run: |
cd SYSTEM
sudo ../libexec/ls-files | sudo tar -cvzf ../${{ matrix.arch }}.tar.gz --no-recursion -T-
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.arch }}
path: ${{ matrix.arch }}.tar.gz
if-no-files-found: error
compression-level: 0
build:
needs: [archive]
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Artifact
uses: actions/download-artifact@v4
- name: Prepare
id: prepare
run: |
mkdir build
mv build-*/* build
- name: Docker Metadata
id: docker-metadata
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=edge
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=schedule
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:master # need qemu >=8.2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64 # ,linux/riscv64
push: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
tags: ${{ steps.docker-metadata.outputs.tags }}
labels: ${{ steps.docker-metadata.outputs.labels }}