Skip to content

Commit e561b9c

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

File tree

2 files changed

+125
-211
lines changed

2 files changed

+125
-211
lines changed

.github/workflows/deploy-template.yml

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

.github/workflows/deploy.yml

+18-211
Original file line numberDiff line numberDiff line change
@@ -6,236 +6,43 @@ 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 }}
1115
strategy:
1216
matrix:
1317
vendor: [ protectli ]
1418
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/"
6419

6520
deploy_novacustom:
66-
runs-on: ubuntu-22.04
6721
if: contains(github.ref, 'refs/tags/novacustom')
22+
uses: ./.github/workflows/deploy-template.yml
23+
with:
24+
platform: novacustom
6825

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/"
12526
deploy_pcengines:
126-
runs-on: ubuntu-22.04
12727
if: contains(github.ref, 'refs/tags/pcengines')
28+
uses: ./.github/workflows/deploy-template.yml
29+
with:
30+
platform: pcengines
31+
vendor: ${{ matrix.vendor }}
32+
model: ${{ matrix.model }}
33+
payload: ${{ matrix.payload }}
12834
strategy:
12935
matrix:
13036
vendor: [ pcengines ]
13137
model: [ apu2, apu3, apu4, apu6 ]
13238
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/"
17939

18040
deploy_msi:
181-
runs-on: ubuntu-22.04
18241
if: contains(github.ref, 'refs/tags/msi')
42+
uses: ./.github/workflows/deploy-template.yml
43+
with:
44+
platform: msi
45+
type: ${{ matrix.type }}
18346
strategy:
18447
matrix:
18548
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)