Skip to content

Commit

Permalink
Add apt update in the homarr workflow
Browse files Browse the repository at this point in the history
create an output directory in / instead of $HOME

fix directory deep creation
  • Loading branch information
Soubinan committed Mar 6, 2024
1 parent a43833b commit 6326304
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 13 deletions.
47 changes: 47 additions & 0 deletions .github/publish_build.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
### create application
POST {{endpoint_url}}
Authorization: Bearer {{token}}

```graphql
mutation CreateApplication {
createApplication(data: {name: "{{app_name}}", source: "{{source}}"}) {
id
}
}
```

### publish application
POST {{endpoint_url}}
Authorization: Bearer {{token}}

```graphql
mutation PublishApplication {
publishApplication(where: {name: "{{app_name}}"}) {
id
}
}
```

### create build
POST {{endpoint_url}}
Authorization: Bearer {{token}}

```graphql
mutation CreateBuild {
createBuild(
data: {buildId: "{{build_id}}", size: "{{size}}", version: "{{app_name}}-{{app_version}}", architecture: "{{arch}}", distribution: "{{dist}}", distRelease: "{{dist_release}}", application: {connect: {name: "{{app_name}}"}}}
)
}
```

### publish build
POST {{endpoint_url}}
Authorization: Bearer {{token}}

```graphql
mutation PublishBuild {
publishBuild(where: {version: "{{app_name}}-{{app_version}}"}) {
id
}
}
```
49 changes: 36 additions & 13 deletions .github/workflows/build-homarr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches:
- main
- dev
paths:
- '**homarr.yml'
- '**.hurl'

env:
PROJECT_URL: https://github.com/soubinan/homelab-lxc
Expand All @@ -25,34 +28,54 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Install Distrobuilder
- name: Install Distrobuilder and tools
run: |
sudo apt-get install -y debootstrap squashfs-tools jq
sudo apt-get update -y
sudo apt-get install -y debootstrap squashfs-tools jq wget
sudo snap install distrobuilder --classic
mkdir $HOME/output/$APP_NAME
mkdir /tmp/cache/$APP_NAME
curl --location --remote-name --url "$(curl -s https://api.github.com/repos/Orange-OpenSource/hurl/releases/latest |jq -r '.assets[] | select(.name|test("amd64.deb")) | .browser_download_url')" -o /tmp/hurl_amd64.deb
mkdir -p /tmp/output/$APP_NAME
mkdir -p /tmp/cache/$APP_NAME
wget $(curl -s https://api.github.com/repos/Orange-OpenSource/hurl/releases/latest |jq -r '.assets[] | select(.name|test("amd64.deb")) | .browser_download_url') -O /tmp/hurl_amd64.deb
sudo apt-get install -y /tmp/hurl_amd64.deb
- name: Get application version
run: |
echo "APP_VERSION="$(curl -s $PROJECT_SOURCE/master/package.json | jq -r ".version") >> $GITHUB_ENV
echo "APP_VERSION=$(curl -s https://raw.githubusercontent.com/ajnart/homarr/master/package.json | jq -r '.version')" >> $GITHUB_ENV
- name: Check out repository code
- name: Check out repository
uses: actions/checkout@v4

- name: Build Image
if: github.event_name == 'pull_request'
run: |
sudo distrobuilder --cache-dir /tmp/cache/$APP_NAME build-lxc ${{ github.workspace }}/templates/${APP_NAME}.yml -o image.distribution=${{ matrix.distribution }} -o image.architecture=${{ matrix.architecture }} -o image.release=${{ matrix.release }} -o image.serial=$APP_VERSION -o source.url="http://ftp.us.debian.org/debian" $HOME/output/$APP_NAME/
mv $HOME/output/$APP_NAME/rootfs.tar.xz $HOME/output/$APP_NAME/$APP_NAME-$APP_VERSION.tar.xz
mv $HOME/output/$APP_NAME/meta.tar.xz $HOME/output/$APP_NAME/$APP_NAME-$APP_VERSION-meta.tar.xz
ls -lash $HOME/output/*
sudo distrobuilder --cache-dir /tmp/cache/$APP_NAME build-lxc ${{github.workspace}}/templates/${APP_NAME}.yml -o image.distribution=${{matrix.distribution}} -o image.architecture=${{matrix.architecture}} -o image.release=${{matrix.release}} -o image.serial="v${APP_VERSION}" -o source.url="http://ftp.us.debian.org/debian" /tmp/output/$APP_NAME/
mv /tmp/output/$APP_NAME/rootfs.tar.xz ./$APP_NAME-$APP_VERSION.tar.xz
mv /tmp/output/$APP_NAME/meta.tar.xz ./$APP_NAME-$APP_VERSION-meta.tar.xz
echo "ARTIFACT_SIZE=$(du -sh ./$APP_NAME-$APP_VERSION.tar.xz| cut -f 1)" >> $GITHUB_ENV
pwd && ls -lash
- name: Upload Artifacts
uses: actions/upload-artifact@v4
id: upload-artifact
with:
name: $APP_NAME-$APP_VERSION
path: $HOME/output/$APP_NAME/$APP_NAME-$APP_VERSION*
name: ${{env.APP_NAME}}-${{env.APP_VERSION}}-${{matrix.architecture}}
path: |
./${{env.APP_NAME}}-${{env.APP_VERSION}}.tar.xz
./${{env.APP_NAME}}-${{env.APP_VERSION}}-meta.tar.xz
retention-days: 45
overwrite: true

- name: Publish build info
run: |
hurl --variable endpoint_url=$HOMELAB_LXC_EP --variable token=$HOMELAB_LXC_TOKEN \
--variable app_name=$APP_NAME --variable app_version=$APP_VERSION \
--variable arch=${{matrix.architecture}} --variable dist=${{matrix.distribution}} \
--variable dist_release=${{matrix.release}} --variable build_id=$BUILD_ID \
--variable size=$ARTIFACT_SIZE --variable source=$PROJECT_SOURCE\
.github/publish_build.hurl
echo 'LXC build published successfully !'
env:
HOMELAB_LXC_EP: ${{secrets.HOMELAB_LXC_EP}}
HOMELAB_LXC_TOKEN: ${{secrets.HOMELAB_LXC_TOKEN}}
BUILD_ID: ${{steps.upload-artifact.outputs.artifact-id}}

0 comments on commit 6326304

Please sign in to comment.