Skip to content

Commit

Permalink
feat: Generate differ entry
Browse files Browse the repository at this point in the history
  • Loading branch information
matbme committed Dec 6, 2023
1 parent 54052d7 commit a0ad33e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .github/gen_package_list.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

packages=""
IFS='
'
for line in $(dpkg -l --no-pager); do
case "$line" in
"ii"*)
items=$(echo "$line" | sed -E "s/\\s+/ /g")
name=$(echo "$items" | cut -d ' ' -f2 | cut -d ':' -f1)
version=$(echo "$items" | cut -d ' ' -f3)
packages="$packages{\"name\":\"$name\",\"version\":\"$version\"},"
;;
esac
done

packages="[${packages%,}]"
printf "\"packages\":%s\n" "$packages"
29 changes: 29 additions & 0 deletions .github/workflows/differ.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Differ

on:
workflow_run:
workflows: [Vib Build]
types:
- completed

jobs:
differ:
runs-on: ubuntu-latest
container:
image: ghcr.io/vanilla-os/pico:main

steps:
- uses: actions/checkout@v4

- name: Generate package diff
run: |
IMAGE_DIGEST=$(curl -s -L -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/Vanilla-OS/packages/container/pico/versions | grep -m1 name | sed -E 's/^\s*"name": "(.+)".*$/\1/')
PACKAGE_LIST=$(.github/gen_package_list.sh)
curl -X POST \
-H 'Accept:application/json' \
-H "Authorization:Basic $(echo -n "${{ secrets.DIFFER_USER }}:${{ secrets.DIFFER_PSW }}" | base64)" \
-d "{\"digest\":\"${IMAGE_DIGEST}\",${PACKAGE_LIST}}" \
$DIFFER_URL/images/pico/new
3 changes: 2 additions & 1 deletion .github/workflows/vib-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
chmod +x vib
./vib build recipe.yml
sed -i '/\/var\/tmp\/*/{d}' Containerfile
- name: Build the Docker image
run: docker image build -f Containerfile --tag ghcr.io/vanilla-os/pico:main .

Expand Down Expand Up @@ -59,4 +60,4 @@ jobs:
name: "Continuous Build"
files: |
rootfs/vanilla-pico.tar.gz
rootfs/SHA256SUMS
rootfs/SHA256SUMS

0 comments on commit a0ad33e

Please sign in to comment.