Skip to content

Commit 2996b9a

Browse files
committed
wip: Add deploy workflow
Signed-off-by: Pawel Langowski <pawel.langowski@3mdeb.com>
1 parent 1cbcd54 commit 2996b9a

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

.github/workflows/deploy.yml

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Deploy
2+
on:
3+
push:
4+
tags:
5+
- '*'
6+
7+
jobs:
8+
deploy_protectli:
9+
runs-on: ubuntu-22.04
10+
if: contains(github.ref, 'refs/tags/protectli')
11+
strategy:
12+
matrix:
13+
vendor: [ protectli ]
14+
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 "::set-output name=tag::${GITHUB_REF#refs/tags/}"
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 "::set-output name=base_dir::$base_dir"
34+
echo "::set-output name=model::$model"
35+
echo "::set-output name=release::$release"
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}.rom.sha256
63+
$CURL_CMD -X PUT -T "${new_name}.rom.sha256" "$BASE_URL/$base_dir/$model/$release/"
64+
65+
deploy_novacustom:
66+
runs-on: ubuntu-22.04
67+
if: contains(github.ref, 'refs/tags/novacustom')
68+
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 "::set-output name=tag::${GITHUB_REF#refs/tags/}"
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 "::set-output name=base_dir::$base_dir"
88+
echo "::set-output name=model::$model"
89+
echo "::set-output name=release::$release"
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 "::set-output name=artifact_name::dasharo-$first_part-$second_part"
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}.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}.rom.sha256
124+
$CURL_CMD -X PUT -T "${new_name}.rom.sha256" "$BASE_URL/$base_dir/$model/$release/"

0 commit comments

Comments
 (0)