-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from soubinan/features
update homarr action
- Loading branch information
Showing
6 changed files
with
249 additions
and
93 deletions.
There are no files selected for viewing
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
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}}"}}}) { | ||
id | ||
} | ||
} | ||
``` | ||
|
||
### publish build | ||
POST {{endpoint_url}} | ||
Authorization: Bearer {{token}} | ||
|
||
```graphql | ||
mutation PublishBuild { | ||
publishBuild(where: {version: "{{app_name}}-{{app_version}}"}) { | ||
id | ||
} | ||
} | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Build Homarr LXC Image | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
- dev | ||
paths: | ||
- '.github/workflows/builder.yml' | ||
- '.github/publish_build.hurl' | ||
- '.github/workflows/build-homarr.yml' | ||
- 'templates/homarr.yml' | ||
schedule: | ||
- cron: '0 */23 * * *' | ||
|
||
jobs: | ||
init: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get Application version | ||
id: get-app-version | ||
run: | | ||
echo "APP_VERSION=$(curl -s https://raw.githubusercontent.com/ajnart/homarr/master/package.json | jq -r '.version')" >> $GITHUB_OUTPUT | ||
outputs: | ||
app_version: ${{steps.get-app-version.outputs.APP_VERSION}} | ||
|
||
image-build: | ||
needs: init | ||
strategy: | ||
matrix: | ||
architectures: | ||
- amd64 | ||
uses: ./.github/workflows/builder.yml | ||
with: | ||
config_path: templates/homarr.yml | ||
app_name: homarr | ||
app_version: ${{needs.init.outputs.app_version}} | ||
project_source: https://github.com/ajnart/homarr | ||
distribution: debian | ||
release: bookworm | ||
architecture: ${{matrix.architectures}} | ||
branch_name: ${{github.event.pull_request.base.ref}} | ||
is_merged: ${{github.event.pull_request.merged}} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Test Build | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
- dev | ||
paths: | ||
- '.github/workflows/builder.yml' | ||
- '.github/publish_build.hurl' | ||
- '.github/workflows/tester.yml' | ||
|
||
jobs: | ||
image-build: | ||
uses: ./.github/workflows/builder.yml | ||
with: | ||
config_path: templates/homarr.yml | ||
app_name: dummy_app # using the homarr config for tests | ||
app_version: '0.15.0' | ||
project_source: https://github.com/soubinan/homelab-lxc | ||
distribution: debian | ||
release: bookworm | ||
architecture: amd64 | ||
branch_name: dev | ||
is_merged: false |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: LXC Image Builder | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
config_path: | ||
required: true | ||
type: string | ||
app_name: | ||
required: true | ||
type: string | ||
app_version: | ||
required: true | ||
type: string | ||
project_source: | ||
required: true | ||
type: string | ||
distribution: | ||
required: true | ||
type: string | ||
architecture: | ||
required: true | ||
type: string | ||
release: | ||
required: true | ||
type: string | ||
branch_name: | ||
required: true | ||
type: string | ||
is_merged: | ||
required: true | ||
type: boolean | ||
|
||
jobs: | ||
image-build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Distrobuilder and other tools | ||
run: | | ||
sudo apt-get update -y | ||
sudo apt-get install -y debootstrap squashfs-tools jq wget curl unzip | ||
sudo snap install distrobuilder --classic | ||
mkdir -p /tmp/output/${{inputs.app_name}} | ||
mkdir -p /tmp/cache/${{inputs.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 | ||
sudo -v ; curl https://rclone.org/install.sh | sudo bash | ||
cat <<EOF > /tmp/rclone.conf | ||
$RCLONE_CONFIG | ||
EOF | ||
env: | ||
RCLONE_CONFIG: ${{secrets.RCLONE_CONFIG}} | ||
|
||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build Image | ||
run: | | ||
sudo distrobuilder --cache-dir /tmp/cache/${{inputs.app_name}} build-lxc ${{github.workspace}}/${CONFIG_PATH} -o image.distribution=${{inputs.distribution}} -o image.architecture=${{inputs.architecture}} -o image.release=${{inputs.release}} -o image.serial="v${{inputs.app_version}}" -o source.url="http://ftp.us.debian.org/debian" /tmp/output/${{inputs.app_name}}/ | ||
mv /tmp/output/${{inputs.app_name}}/rootfs.tar.xz ./${{inputs.app_name}}-${{inputs.app_version}}-${{inputs.architecture}}.tar.xz | ||
mv /tmp/output/${{inputs.app_name}}/meta.tar.xz ./${{inputs.app_name}}-${{inputs.app_version}}-${{inputs.architecture}}-meta.tar.xz | ||
echo "ARTIFACT_SIZE=$(du -sh ./${{inputs.app_name}}-${{inputs.app_version}}-${{inputs.architecture}}.tar.xz| cut -f 1)" >> $GITHUB_ENV | ||
pwd && ls -lash | ||
env: | ||
CONFIG_PATH: ${{inputs.config_path}} | ||
|
||
- name: Publish Image files | ||
if: github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true | ||
run: | | ||
rclone copy ./${{inputs.app_name}}-${{inputs.app_version}}-${{inputs.architecture}}.tar.xz cloudflare:lxc-images --config /tmp/rclone.conf | ||
rclone copy ./${{inputs.app_name}}-${{inputs.app_version}}-${{inputs.architecture}}-meta.tar.xz cloudflare:lxc-images --config /tmp/rclone.conf | ||
echo | ||
echo 'LXC Image published successfully !' | ||
env: | ||
RCLONE_CONFIG_PASS: ${{secrets.RCLONE_CONFIG_PASS}} | ||
|
||
- name: Publish build info | ||
if: inputs.branch_name == 'main' && inputs.is_merged == true | ||
run: | | ||
hurl --variable endpoint_url=$HOMELAB_LXC_EP --variable token=$HOMELAB_LXC_TOKEN \ | ||
--variable app_name=${{inputs.app_name}} --variable app_version=${{inputs.app_version}} \ | ||
--variable arch=${{inputs.architecture}} --variable dist=${{inputs.distribution}} \ | ||
--variable dist_release=${{inputs.release}} --variable build_id=${{inputs.app_name}}-${{inputs.app_version}}-${{inputs.architecture}}.tar.xz\ | ||
--variable size=$ARTIFACT_SIZE --variable source=${{inputs.project_source}}\ | ||
.github/publish_build.hurl | ||
echo | ||
echo 'LXC build published successfully !' | ||
env: | ||
HOMELAB_LXC_EP: ${{secrets.HOMELAB_LXC_EP}} | ||
HOMELAB_LXC_TOKEN: ${{secrets.HOMELAB_LXC_TOKEN}} |
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