Skip to content

Commit b9a8b17

Browse files
committed
wip: reusable workflow
Signed-off-by: Pawel Langowski <pawel.langowski@3mdeb.com>
1 parent c3e6510 commit b9a8b17

File tree

2 files changed

+136
-211
lines changed

2 files changed

+136
-211
lines changed

.github/workflows/deploy-template.yml

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Reusable Deploy workflow
2+
on:
3+
workflow_call:
4+
inputs:
5+
platform:
6+
type: string
7+
vendor:
8+
type: string
9+
required: false
10+
model:
11+
type: string
12+
required: false
13+
payload:
14+
type: string
15+
required: false
16+
type:
17+
type: string
18+
required: false
19+
CLOUD_URL:
20+
type: string
21+
required: false
22+
CLOUD_PASSWORD:
23+
type: string
24+
required: false
25+
26+
jobs:
27+
deploy:
28+
runs-on: ubuntu-22.04
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
33+
- name: Set up tag name
34+
id: tag_name
35+
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
36+
37+
- name: Parse directories
38+
id: parse_directories
39+
run: |
40+
tag=${{ steps.tag_name.outputs.tag }}
41+
if [ "${{ inputs.platform }}" == "protectli" ]; then
42+
base_dir="protectli"
43+
model=$(echo "$tag" | cut -d'_' -f1-3)
44+
release=$(echo "$tag" | cut -d'_' -f4)
45+
elif [ "${{ inputs.platform }}" == "novacustom" ]; then
46+
base_dir="novacustom"
47+
model=$(echo "$tag" | cut -d'_' -f1-3)
48+
release=$(echo "$tag" | cut -d'_' -f4)
49+
elif [ "${{ inputs.platform }}" == "pcengines" ]; then
50+
base_dir="pcengines"
51+
model="pcengines_apu2"
52+
release=$(echo "$tag" | cut -d'_' -f3)
53+
elif [ "${{ inputs.platform }}" == "msi" ]; then
54+
base_dir="msi"
55+
model=$(echo "$tag" | cut -d'_' -f1-2)
56+
release=$(echo "$tag" | cut -d'_' -f3)
57+
fi
58+
echo "base_dir=$base_dir" >> "$GITHUB_OUTPUT"
59+
echo "model=$model" >> "$GITHUB_OUTPUT"
60+
echo "release=$release" >> "$GITHUB_OUTPUT"
61+
62+
- name: Parse artifact name
63+
id: artifact_name
64+
run: |
65+
if [ "${{ inputs.platform }}" == "protectli" ]; then
66+
echo "artifact_name=dasharo-${{ inputs.vendor }}-${{ inputs.model }}" >> "$GITHUB_OUTPUT"
67+
elif [ "${{ inputs.platform }}" == "novacustom" ]; then
68+
first_part=$(echo ${{ steps.tag_name.outputs.tag }} | cut -d "_" -f1)
69+
second_part=$(echo ${{ steps.tag_name.outputs.tag }} | cut -d "_" -f2-3)
70+
echo "artifact_name=dasharo-$first_part-$second_part" >> "$GITHUB_OUTPUT"
71+
elif [ "${{ inputs.platform }}" == "pcengines" ]; then
72+
echo "artifact_name=dasharo-${{ inputs.vendor }}-${{ inputs.model }}-${{ inputs.payload }}" >> "$GITHUB_OUTPUT"
73+
elif [ "${{ inputs.platform }}" == "msi" ]; then
74+
first_part=$(echo ${{ steps.tag_name.outputs.tag }} | cut -d "_" -f1)
75+
second_part=$(echo ${{ steps.tag_name.outputs.tag }} | cut -d "_" -f2)
76+
echo "artifact_name=dasharo-$first_part-${second_part}_${{ inputs.type }}" >> "$GITHUB_OUTPUT"
77+
fi
78+
79+
# Allows downloading artifacts from a different workflow
80+
- name: Download workflow artifact
81+
uses: dawidd6/action-download-artifact@v6
82+
with:
83+
workflow: build.yml
84+
name: ${{ steps.artifact_name.outputs.artifact_name }}
85+
path: "./artifacts"
86+
87+
- name: Upload to Nextcloud
88+
run: |
89+
BASE_URL="https://cloud.3mdeb.com/public.php/webdav"
90+
url_part=$(echo "${{ inputs.CLOUD_URL }}" | cut -d'/' -f6)
91+
base_dir="${{ steps.parse_directories.outputs.base_dir }}"
92+
model="${{ steps.parse_directories.outputs.model }}"
93+
release="${{ steps.parse_directories.outputs.release }}"
94+
CURL_CMD="curl -u $url_part:${{ CLOUD_PASSWORD }}"
95+
96+
if [ "${{ inputs.platform }}" == "protectli" ]; then
97+
new_name=$(echo "${{ inputs.vendor }}-${{ inputs.model }}.rom" | sed 's/-/_/g; s/.*/\L&/')
98+
elif [ "${{ inputs.platform }}" == "novacustom" ]; then
99+
new_name=$(echo "${model}_${release}.rom" | sed 's/-/_/g; s/.*/\L&/')
100+
elif [ "${{ inputs.platform }}" == "pcengines" ]; then
101+
new_name=$(echo "${{ inputs.vendor }}_${{ inputs.model }}_${{ inputs.payload }}_${release}.rom" | sed 's/.*/\L&/')
102+
elif [ "${{ inputs.platform }}" == "msi" ]; then
103+
new_name=$(echo "${model}_${{ inputs.type }}_${release}.rom" | sed 's/-/_/g; s/.*/\L&/')
104+
fi
105+
106+
# Create release directory if it doesn't exist
107+
$CURL_CMD -X MKCOL "$BASE_URL/$base_dir/$model/$release"
108+
$CURL_CMD -X PUT -T "artifacts/coreboot.rom" "$BASE_URL/$base_dir/$model/$release/$new_name"
109+
sha256sum artifacts/coreboot.rom > ${new_name}.sha256
110+
$CURL_CMD -X PUT -T "${new_name}.sha256" "$BASE_URL/$base_dir/$model/$release/"

.github/workflows/deploy.yml

+26-211
Original file line numberDiff line numberDiff line change
@@ -6,236 +6,51 @@ on:
66

77
jobs:
88
deploy_protectli:
9-
runs-on: ubuntu-22.04
109
if: contains(github.ref, 'refs/tags/protectli')
10+
uses: ./.github/workflows/deploy-template.yml
11+
with:
12+
platform: protectli
13+
vendor: ${{ matrix.vendor }}
14+
model: ${{ matrix.model }}
15+
CLOUD_URL: ${{ secrets.CLOUD_URL }}
16+
CLOUD_PASSWORD: ${{ secrets.CLOUD_PASSWORD }}
1117
strategy:
1218
matrix:
1319
vendor: [ protectli ]
1420
model: [ vp66xx, vp46xx, vp2420, vp2410, V1210, V1211, V1410, V1610 ]
15-
steps:
16-
- name: Checkout repository
17-
uses: actions/checkout@v4
18-
19-
- name: Checkout all submodules
20-
run: git submodule update --init --recursive --checkout
21-
22-
- name: Set up tag name
23-
id: tag_name
24-
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
25-
26-
- name: Parse directories from tag
27-
id: parse_directories
28-
run: |
29-
tag=${{ steps.tag_name.outputs.tag }}
30-
base_dir="protectli"
31-
model=$(echo "$tag" | cut -d'_' -f1-3)
32-
release=$(echo "$tag" | cut -d'_' -f4)
33-
echo "base_dir=$base_dir" >> "$GITHUB_OUTPUT"
34-
echo "model=$model" >> "$GITHUB_OUTPUT"
35-
echo "release=$release" >> "$GITHUB_OUTPUT"
36-
37-
# Allows downloading artifacts from a different workflow
38-
- name: Download workflow artifact
39-
uses: dawidd6/action-download-artifact@v6
40-
with:
41-
workflow: build.yml
42-
name: "dasharo-${{ matrix.vendor }}-${{ matrix.model }}"
43-
path: "./artifacts"
44-
45-
- name: Upload to Nextcloud
46-
env:
47-
CLOUD_URL: ${{ secrets.CLOUD_URL }}
48-
CLOUD_PASSWORD: ${{ secrets.CLOUD_PASSWORD }}
49-
run: |
50-
BASE_URL="https://cloud.3mdeb.com/public.php/webdav"
51-
url_part=$(echo "$CLOUD_URL" | cut -d'/' -f6)
52-
base_dir="${{ steps.parse_directories.outputs.base_dir }}"
53-
model="${{ steps.parse_directories.outputs.model }}"
54-
release="${{ steps.parse_directories.outputs.release }}"
55-
CURL_CMD="curl -u $url_part:$CLOUD_PASSWORD"
56-
57-
new_name=$(echo "${{ matrix.vendor }}-${{ matrix.model }}.rom" | sed 's/-/_/g; s/.*/\L&/')
58-
59-
# Create release directory if it doesn't exist
60-
$CURL_CMD -X MKCOL "$BASE_URL/$base_dir/$model/$release"
61-
$CURL_CMD -X PUT -T "artifacts/coreboot.rom" "$BASE_URL/$base_dir/$model/$release/$new_name"
62-
sha256sum artifacts/coreboot.rom > ${new_name}.sha256
63-
$CURL_CMD -X PUT -T "${new_name}.sha256" "$BASE_URL/$base_dir/$model/$release/"
6421

6522
deploy_novacustom:
66-
runs-on: ubuntu-22.04
6723
if: contains(github.ref, 'refs/tags/novacustom')
24+
uses: ./.github/workflows/deploy-template.yml
25+
with:
26+
platform: novacustom
27+
CLOUD_URL: ${{ secrets.CLOUD_URL }}
28+
CLOUD_PASSWORD: ${{ secrets.CLOUD_PASSWORD }}
6829

69-
steps:
70-
- name: Checkout repository
71-
uses: actions/checkout@v4
72-
73-
- name: Checkout all submodules
74-
run: git submodule update --init --recursive --checkout
75-
76-
- name: Set up tag name
77-
id: tag_name
78-
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
79-
80-
- name: Parse directories from tag
81-
id: parse_directories
82-
run: |
83-
tag=${{ steps.tag_name.outputs.tag }}
84-
base_dir="novacustom"
85-
model=$(echo "$tag" | cut -d'_' -f1-3)
86-
release=$(echo "$tag" | cut -d'_' -f4)
87-
echo "base_dir=$base_dir" >> "$GITHUB_OUTPUT"
88-
echo "model=$model" >> "$GITHUB_OUTPUT"
89-
echo "release=$release" >> "$GITHUB_OUTPUT"
90-
91-
- name: Parse artifact name
92-
id: artifact_name
93-
run: |
94-
first_part=$(echo ${{ steps.tag_name.outputs.tag }} | cut -d "_" -f1)
95-
second_part=$(echo ${{ steps.tag_name.outputs.tag }} | cut -d "_" -f2-3)
96-
echo "artifact_name=dasharo-$first_part-$second_part" >> "$GITHUB_OUTPUT"
97-
98-
# Allows downloading artifacts from a different workflow
99-
- name: Download workflow artifact
100-
uses: dawidd6/action-download-artifact@v6
101-
with:
102-
workflow: build.yml
103-
name: ${{ steps.artifact_name.outputs.artifact_name }}
104-
path: "./artifacts"
105-
106-
- name: Upload to Nextcloud
107-
env:
108-
CLOUD_URL: ${{ secrets.CLOUD_URL }}
109-
CLOUD_PASSWORD: ${{ secrets.CLOUD_PASSWORD }}
110-
run: |
111-
BASE_URL="https://cloud.3mdeb.com/public.php/webdav"
112-
url_part=$(echo "$CLOUD_URL" | cut -d'/' -f6)
113-
base_dir="${{ steps.parse_directories.outputs.base_dir }}"
114-
model="${{ steps.parse_directories.outputs.model }}"
115-
release="${{ steps.parse_directories.outputs.release }}"
116-
CURL_CMD="curl -u $url_part:$CLOUD_PASSWORD"
117-
118-
new_name=$(echo "${model}_${release}.rom" | sed 's/-/_/g; s/.*/\L&/')
119-
120-
# Create release directory if it doesn't exist
121-
$CURL_CMD -X MKCOL "$BASE_URL/$base_dir/$model/$release"
122-
$CURL_CMD -X PUT -T "artifacts/coreboot.rom" "$BASE_URL/$base_dir/$model/$release/$new_name"
123-
sha256sum artifacts/coreboot.rom > ${new_name}.sha256
124-
$CURL_CMD -X PUT -T "${new_name}.sha256" "$BASE_URL/$base_dir/$model/$release/"
12530
deploy_pcengines:
126-
runs-on: ubuntu-22.04
12731
if: contains(github.ref, 'refs/tags/pcengines')
32+
uses: ./.github/workflows/deploy-template.yml
33+
with:
34+
platform: pcengines
35+
vendor: ${{ matrix.vendor }}
36+
model: ${{ matrix.model }}
37+
payload: ${{ matrix.payload }}
38+
CLOUD_URL: ${{ secrets.CLOUD_URL }}
39+
CLOUD_PASSWORD: ${{ secrets.CLOUD_PASSWORD }}
12840
strategy:
12941
matrix:
13042
vendor: [ pcengines ]
13143
model: [ apu2, apu3, apu4, apu6 ]
13244
payload: [ uefi ]
133-
steps:
134-
- name: Checkout repository
135-
uses: actions/checkout@v4
136-
137-
- name: Checkout all submodules
138-
run: git submodule update --init --recursive --checkout
139-
140-
- name: Set up tag name
141-
id: tag_name
142-
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
143-
144-
- name: Parse directories from tag
145-
id: parse_directories
146-
run: |
147-
tag=${{ steps.tag_name.outputs.tag }}
148-
base_dir="pcengines"
149-
release=$(echo "$tag" | cut -d'_' -f3)
150-
echo "base_dir=$base_dir" >> "$GITHUB_OUTPUT"
151-
echo "release=$release" >> "$GITHUB_OUTPUT"
152-
153-
# Allows downloading artifacts from a different workflow
154-
- name: Download workflow artifact
155-
uses: dawidd6/action-download-artifact@v6
156-
with:
157-
workflow: build.yml
158-
name: "dasharo-${{ matrix.vendor }}-${{ matrix.model }}-${{ matrix.payload }}"
159-
path: "./artifacts"
160-
161-
- name: Upload to Nextcloud
162-
env:
163-
CLOUD_URL: ${{ secrets.CLOUD_URL }}
164-
CLOUD_PASSWORD: ${{ secrets.CLOUD_PASSWORD }}
165-
run: |
166-
BASE_URL="https://cloud.3mdeb.com/public.php/webdav"
167-
url_part=$(echo "$CLOUD_URL" | cut -d'/' -f6)
168-
base_dir="${{ steps.parse_directories.outputs.base_dir }}"
169-
release="${{ steps.parse_directories.outputs.release }}"
170-
CURL_CMD="curl -u $url_part:$CLOUD_PASSWORD"
171-
172-
new_name=$(echo "${{ matrix.vendor }}_${{ matrix.model }}_${{ matrix.payload }}_${release}.rom" | sed 's/.*/\L&/')
173-
174-
# Create release directory if it doesn't exist
175-
$CURL_CMD -X MKCOL "$BASE_URL/$base_dir/pcengines_apu2/$release"
176-
$CURL_CMD -X PUT -T "artifacts/coreboot.rom" "$BASE_URL/$base_dir/pcengines_apu2/$release/$new_name"
177-
sha256sum artifacts/coreboot.rom > ${new_name}.sha256
178-
$CURL_CMD -X PUT -T "${new_name}.sha256" "$BASE_URL/$base_dir/pcengines_apu2/$release/"
17945

18046
deploy_msi:
181-
runs-on: ubuntu-22.04
18247
if: contains(github.ref, 'refs/tags/msi')
48+
uses: ./.github/workflows/deploy-template.yml
49+
with:
50+
platform: msi
51+
type: ${{ matrix.type }}
52+
CLOUD_URL: ${{ secrets.CLOUD_URL }}
53+
CLOUD_PASSWORD: ${{ secrets.CLOUD_PASSWORD }}
18354
strategy:
18455
matrix:
18556
type: [ ddr4, ddr5 ]
186-
steps:
187-
- name: Checkout repository
188-
uses: actions/checkout@v4
189-
190-
- name: Checkout all submodules
191-
run: git submodule update --init --recursive --checkout
192-
193-
- name: Set up tag name
194-
id: tag_name
195-
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
196-
197-
- name: Parse directories from tag
198-
id: parse_directories
199-
run: |
200-
tag=${{ steps.tag_name.outputs.tag }}
201-
base_dir="msi"
202-
model=$(echo "$tag" | cut -d'_' -f1-2)
203-
release=$(echo "$tag" | cut -d'_' -f3)
204-
echo "base_dir=$base_dir" >> "$GITHUB_OUTPUT"
205-
echo "model=$model" >> "$GITHUB_OUTPUT"
206-
echo "release=$release" >> "$GITHUB_OUTPUT"
207-
208-
- name: Parse artifact name
209-
id: artifact_name
210-
run: |
211-
first_part=$(echo ${{ steps.tag_name.outputs.tag }} | cut -d "_" -f1)
212-
second_part=$(echo ${{ steps.tag_name.outputs.tag }} | cut -d "_" -f2)
213-
echo "artifact_name=dasharo-$first_part-${second_part}_${{ matrix.type }}" >> "$GITHUB_OUTPUT"
214-
215-
# Allows downloading artifacts from a different workflow
216-
- name: Download workflow artifact
217-
uses: dawidd6/action-download-artifact@v6
218-
with:
219-
workflow: build.yml
220-
name: ${{ steps.artifact_name.outputs.artifact_name }}
221-
path: "./artifacts"
222-
223-
- name: Upload to Nextcloud
224-
env:
225-
CLOUD_URL: ${{ secrets.CLOUD_URL }}
226-
CLOUD_PASSWORD: ${{ secrets.CLOUD_PASSWORD }}
227-
run: |
228-
BASE_URL="https://cloud.3mdeb.com/public.php/webdav"
229-
url_part=$(echo "$CLOUD_URL" | cut -d'/' -f6)
230-
base_dir="${{ steps.parse_directories.outputs.base_dir }}"
231-
model="${{ steps.parse_directories.outputs.model }}"
232-
release="${{ steps.parse_directories.outputs.release }}"
233-
CURL_CMD="curl -u $url_part:$CLOUD_PASSWORD"
234-
235-
new_name=$(echo "${model}_${{ matrix.type }}_${release}.rom" | sed 's/-/_/g; s/.*/\L&/')
236-
237-
# Create release directory if it doesn't exist
238-
$CURL_CMD -X MKCOL "$BASE_URL/$base_dir/$model/$release"
239-
$CURL_CMD -X PUT -T "artifacts/coreboot.rom" "$BASE_URL/$base_dir/$model/$release/$new_name"
240-
sha256sum artifacts/coreboot.rom > ${new_name}.sha256
241-
$CURL_CMD -X PUT -T "${new_name}.sha256" "$BASE_URL/$base_dir/$model/$release/"

0 commit comments

Comments
 (0)