Skip to content

Commit

Permalink
feat: Add Differ integration
Browse files Browse the repository at this point in the history
  • Loading branch information
matbme committed Dec 6, 2023
1 parent 4b4a7f3 commit 877ef01
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
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"
30 changes: 30 additions & 0 deletions .github/workflows/differ.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Differ

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

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

steps:
- uses: actions/checkout@v4

- name: Generate package diff
run: |
PACKAGE_LIST=$(.github/gen_package_list.sh)
apt-get install -y curl
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/desktop/versions | grep -m1 name | sed -E 's/^\s*"name": "(.+)".*$/\1/')
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}}" \
${{ vars.DIFFER_URL }}/images/desktop/new

0 comments on commit 877ef01

Please sign in to comment.