Create USB setup file #76
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: Create USB setup file | |
on: | |
schedule: | |
# Run every thursday at midnight | |
- cron: '0 0 * * THU' | |
pull_request: | |
push: | |
paths: | |
- 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: | |
download-packages: | |
runs-on: ubuntu-20.04 | |
permissions: | |
contents: "read" | |
id-token: "write" | |
steps: | |
- name: GitHub Environment Variables Action | |
uses: FranzDiebold/github-env-vars-action@v2.7.0 | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update && sudo apt-get install -y \ | |
systemd-container \ | |
qemu-user-static | |
- 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: | |
path: | | |
updates.tar.gz | |
key: ${{ runner.os }}-packages | |
- 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: | |
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: List downloaded packages | |
run: | | |
ls -lh "${{ env.PACKAGES_FOLDER }}" | |
- name: Compress downloaded packages | |
run: | | |
mkdir -p pi-top-usb-setup | |
sudo mv ${{ env.PACKAGES_FOLDER }} pi-top-usb-setup/ | |
sudo chown -R $USER:$USER pi-top-usb-setup | |
sudo chmod -R 755 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' | |
with: | |
path: "." | |
glob: "pi-top-usb-setup.tar.gz" | |
parent: false | |
destination: "${{ secrets.GCS_PACKAGES_UPLOAD_BUCKET }}/" | |
- name: Upload as artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: files | |
path: | | |
packages.list | |
pi-top-usb-setup.tar.gz | |
- name: Report to slack | |
if: github.ref == 'refs/heads/master' && always() | |
uses: slackapi/slack-github-action@v1.25.0 | |
with: | |
channel-id: 'C02UEAAHK3R' | |
slack-message: "pi-top-Offline-Updates: create-usb-setup-file workflow run.\nStatus: ${{ job.status }}\nUrl: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_PACKAGE_PROMOTER_TOKEN }} |