Skip to content

Commit

Permalink
Download packages and create bundle in 1 workflow (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcapona authored Nov 2, 2023
1 parent 709fe54 commit 35a64e0
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 124 deletions.
85 changes: 69 additions & 16 deletions .github/workflows/create-usb-setup-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ on:
pull_request:
push:
paths:
- .github/workflows/create-usb-setup-file.yml
- download-packages.sh
- .github/workflows/download-packages.yml
branches:
- master
workflow_dispatch:

env:
PI_TOP_OS_URL: "https://storage.googleapis.com/pt-os-release/pi-topOS-bullseye/pi-topOS_bullseye_release_armhf_2023-05-23_B25.zip"
MOUNT_POINT: "/tmp/pi-top-os"
PACKAGES_FOLDER: "updates"

jobs:
create-usb-setup-file:
download-packages:
runs-on: ubuntu-20.04

permissions:
Expand All @@ -21,30 +27,76 @@ jobs:
- name: GitHub Environment Variables Action
uses: FranzDiebold/github-env-vars-action@v2.7.0

- name: Authenticate with GCP
uses: "google-github-actions/auth@v1.1.1"
- name: Checkout code
uses: actions/checkout@v3
with:
credentials_json: ${{ secrets.WEB_GCR_UPLOAD_KEY }}
fetch-depth: 0

- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -y \
systemd-container \
qemu-user-static
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
- name: Get pi-topOS image filename
run: |
echo "IMAGE_FILE=$(basename ${{ env.PI_TOP_OS_URL }} | cut -d'.' -f1).img" >> $GITHUB_ENV
- name: Download pi-topOS image
run: |
wget "${{ env.PI_TOP_OS_URL }}" -O pi-topOS.zip
unzip pi-topOS.zip
- name: Cache packages
uses: actions/cache@v3
id: cache-packages
with:
version: '>= 363.0.0'
path: |
updates.tar.gz
key: ${{ runner.os }}-packages

- name: Download updates file from GCS
uses: nick-fields/retry@v2
- name: Extract cached debs
if: steps.cache-packages.outputs.cache-hit == 'true'
run: |
ls -lh
tar -xf updates.tar.gz
ls -lh "${{ env.PACKAGES_FOLDER }}"
- name: Mount OS Image root partition
uses: jcapona/mount-image-partition-action@v0.3
with:
timeout_minutes: 30
max_attempts: 30
command: gsutil -m cp "gs://${{ secrets.GCS_PACKAGES_UPLOAD_BUCKET }}/updates.tar.gz" .
imagePath: ${{ env.IMAGE_FILE }}
mountPoint: ${{ env.MOUNT_POINT }}
partitionIndex: 3
filesystem: ext4

- name: Update pi-topOS container and download packages
run: |
sudo systemd-nspawn --pipe --bind "$PWD":/packages -D "${{ env.MOUNT_POINT }}" /bin/bash << EOF
apt update
DEBIAN_FRONTEND=noninteractive apt dist-upgrade -y
cd /packages
ls -lh
bash ./download-packages.sh
EOF
- name: Prepare folder structure
- name: List downloaded packages
run: |
ls -lh "${{ env.PACKAGES_FOLDER }}"
- name: Compress downloaded packages
run: |
mkdir -p pi-top-usb-setup
tar -xvf updates.tar.gz -C pi-top-usb-setup/
mv ${{ env.PACKAGES_FOLDER }} pi-top-usb-setup/
tar -czvf pi-top-usb-setup.tar.gz pi-top-usb-setup
ls -lhR
- name: Authenticate with GCP
uses: "google-github-actions/auth@v1.1.1"
if: github.ref == 'refs/heads/master'
with:
credentials_json: ${{ secrets.WEB_GCR_UPLOAD_KEY }}

- name: Upload to GCS
uses: google-github-actions/upload-cloud-storage@v1.0.3
if: github.ref == 'refs/heads/master'
Expand All @@ -57,6 +109,7 @@ jobs:
- name: Upload as artifact
uses: actions/upload-artifact@v3
with:
name: pi-top-usb-setup
name: files
path: |
packages.list
pi-top-usb-setup.tar.gz
108 changes: 0 additions & 108 deletions .github/workflows/download-packages.yml

This file was deleted.

0 comments on commit 35a64e0

Please sign in to comment.