Skip to content

Commit c479fd7

Browse files
committed
chore: initial cleanup
1 parent a562f77 commit c479fd7

File tree

2 files changed

+210
-179
lines changed

2 files changed

+210
-179
lines changed

.github/workflows/build-plugin.yml

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
name: Build Plugin Component
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
RELEASE_CREATED:
7+
type: boolean
8+
required: true
9+
description: "Whether a release was created"
10+
TAG:
11+
type: string
12+
required: false
13+
description: "Tag for the build (e.g. PR number or version)"
14+
BUCKET_PATH:
15+
type: string
16+
required: true
17+
description: "Path in the bucket where artifacts should be stored"
18+
BASE_URL:
19+
type: string
20+
required: true
21+
description: "Base URL for the plugin builds"
22+
secrets:
23+
CF_ACCESS_KEY_ID:
24+
required: true
25+
CF_SECRET_ACCESS_KEY:
26+
required: true
27+
CF_BUCKET_PREVIEW:
28+
required: true
29+
CF_ENDPOINT:
30+
required: true
31+
GITHUB_TOKEN:
32+
required: true
33+
jobs:
34+
build-plugin:
35+
name: Build and Deploy Plugin
36+
defaults:
37+
run:
38+
working-directory: plugin
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout repo
42+
uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
46+
- name: Install Node
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version-file: ".nvmrc"
50+
51+
- uses: pnpm/action-setup@v4
52+
name: Install pnpm
53+
with:
54+
run_install: false
55+
56+
- name: Get pnpm store directory
57+
id: pnpm-cache
58+
shell: bash
59+
run: |
60+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
61+
62+
- name: Get API Version
63+
id: vars
64+
run: |
65+
GIT_SHA=$(git rev-parse --short HEAD)
66+
IS_TAGGED=$(git describe --tags --abbrev=0 --exact-match || echo '')
67+
PACKAGE_LOCK_VERSION=$(jq -r '.version' package.json)
68+
API_VERSION=$([[ -n "$IS_TAGGED" ]] && echo "$PACKAGE_LOCK_VERSION" || echo "${PACKAGE_LOCK_VERSION}+${GIT_SHA}")
69+
echo "API_VERSION=${API_VERSION}" >> $GITHUB_OUTPUT
70+
71+
- uses: actions/cache@v4
72+
name: Setup pnpm cache
73+
with:
74+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
75+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
76+
restore-keys: |
77+
${{ runner.os }}-pnpm-store-
78+
79+
- name: Install dependencies
80+
run: |
81+
cd ${{ github.workspace }}
82+
pnpm install --frozen-lockfile --filter @unraid/connect-plugin
83+
84+
- name: Download Unraid UI Components
85+
uses: actions/download-artifact@v4
86+
with:
87+
name: unraid-wc-ui
88+
path: ${{ github.workspace }}/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components/uui
89+
merge-multiple: true
90+
- name: Download Unraid Web Components
91+
uses: actions/download-artifact@v4
92+
with:
93+
pattern: unraid-wc-rich
94+
path: ${{ github.workspace }}/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components/nuxt
95+
merge-multiple: true
96+
- name: Download Unraid API
97+
uses: actions/download-artifact@v4
98+
with:
99+
name: unraid-api
100+
path: ${{ github.workspace }}/plugin/api/
101+
- name: Download PNPM Store
102+
uses: actions/download-artifact@v4
103+
with:
104+
name: packed-pnpm-store
105+
path: ${{ github.workspace }}/plugin/
106+
- name: Extract Unraid API
107+
run: |
108+
mkdir -p ${{ github.workspace }}/plugin/source/dynamix.unraid.net/usr/local/unraid-api
109+
tar -xzf ${{ github.workspace }}/plugin/api/unraid-api.tgz -C ${{ github.workspace }}/plugin/source/dynamix.unraid.net/usr/local/unraid-api
110+
- name: Build Plugin and TXZ Based on Event and Tag
111+
id: build-plugin
112+
run: |
113+
cd ${{ github.workspace }}/plugin
114+
ls -al
115+
pnpm run build:txz
116+
pnpm run build:plugin --tag="${{ inputs.TAG }}" --base-url="${{ inputs.BASE_URL }}"
117+
118+
- name: Ensure Plugin Files Exist
119+
run: |
120+
ls -al ./deploy
121+
if [ ! -f ./deploy/*.plg ]; then
122+
echo "Error: .plg file not found in plugin/deploy/"
123+
exit 1
124+
fi
125+
126+
if [ ! -f ./deploy/*.txz ]; then
127+
echo "Error: .txz file not found in plugin/deploy/"
128+
exit 1
129+
fi
130+
131+
- name: Upload to GHA
132+
uses: actions/upload-artifact@v4
133+
with:
134+
name: unraid-plugin
135+
path: plugin/deploy/
136+
137+
- name: Upload Release Assets
138+
if: inputs.RELEASE_CREATED == 'true'
139+
env:
140+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141+
run: |
142+
release_name=$(gh release list --repo ${{ github.repository }} --json name,isDraft --jq '.[] | select(.isDraft == true) | .name' | head -n 1)
143+
# For each file in release directory
144+
for file in deploy-prod/*; do
145+
echo "Uploading $file to release..."
146+
gh release upload "${release_name}" "$file" --clobber
147+
done
148+
149+
- name: Upload to Cloudflare
150+
if: inputs.RELEASE_CREATED == 'false'
151+
env:
152+
AWS_ACCESS_KEY_ID: ${{ secrets.CF_ACCESS_KEY_ID }}
153+
AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_SECRET_ACCESS_KEY }}
154+
AWS_DEFAULT_REGION: auto
155+
run: |
156+
# Sync the deploy directory to the Cloudflare bucket with explicit content encoding and public-read ACL
157+
aws s3 sync deploy/ s3://${{ secrets.CF_BUCKET_PREVIEW }}/${{ inputs.BUCKET_PATH }} \
158+
--endpoint-url ${{ secrets.CF_ENDPOINT }} \
159+
--checksum-algorithm CRC32 \
160+
--no-guess-mime-type \
161+
--content-encoding none \
162+
--acl public-read
163+
164+
- name: Comment URL
165+
if: github.event_name == 'pull_request'
166+
uses: thollander/actions-comment-pull-request@v3
167+
with:
168+
comment-tag: prlink
169+
mode: recreate
170+
message: |
171+
This plugin has been deployed to Cloudflare R2 and is available for testing.
172+
Download it at this URL:
173+
```
174+
${{ inputs.BASE_URL }}/tag/${{ inputs.TAG }}/dynamix.unraid.net.plg
175+
```

0 commit comments

Comments
 (0)