-
-
Notifications
You must be signed in to change notification settings - Fork 13
96 lines (85 loc) · 3.36 KB
/
deploy-template.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Reusable Deploy workflow
on:
workflow_call:
inputs:
platform:
type: string
vendor:
type: string
required: false
model:
type: string
required: false
payload:
type: string
required: false
type:
type: string
required: false
artifact_name:
type: string
# Set to true for DPP/community releases by 3mdeb
released_by_3mdeb:
type: boolean
jobs:
deploy:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up tag name
id: tag_name
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
- name: Parse directories
id: parse_directories
run: |
tag=${{ steps.tag_name.outputs.tag }}
# Extract platform model string (everything before the last underscore in the tag)
model=$(echo "$tag" | awk -F'_' '{OFS="_"; $(NF)=""; print $0}' | sed 's/_$//')
# Extract version string (everything after the last underscore in the tag)
release=$(echo "$tag" | awk -F'_' '{print $NF}')
# Use 3mdeb directory for community / DPP releases
if ${{ inputs.released_by_3mdeb }} ; then
base_dir="3mdeb"
else
# by default, use platform vendor name as a directory
base_dir="${{ inputs.platform }}"
fi
echo "base_dir=$base_dir" >> "$GITHUB_OUTPUT"
echo "model=$model" >> "$GITHUB_OUTPUT"
echo "release=$release" >> "$GITHUB_OUTPUT"
- name: Download workflow artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact_name }}
path: "./artifacts"
- name: Upload to Nextcloud
run: |
BASE_URL="https://cloud.3mdeb.com/public.php/webdav"
url_part=$(echo "${{ secrets.CLOUD_URL }}" | cut -d'/' -f6)
base_dir="${{ steps.parse_directories.outputs.base_dir }}"
model="${{ steps.parse_directories.outputs.model }}"
release="${{ steps.parse_directories.outputs.release }}"
CURL_CMD="curl -u $url_part:${{ secrets.CLOUD_PASSWORD }}"
if [ "${{ inputs.platform }}" == "pcengines" ]; then
new_name="pcengines_${{ inputs.model }}_${release}.rom"
else
new_name="${{ inputs.model }}_${release}.rom"
if [ ! -z "${{ inputs.vendor }}" ]; then
new_name="${{ inputs.vendor }}_${new_name}"
fi
if [ ! -z "${{ inputs.payload }}" ]; then
new_name=$(echo "$new_name" | awk -F'_' '{OFS="_"; $NF="${{ inputs.payload }}_"$NF; print}')
fi
if [ ! -z "${{ inputs.type }}" ]; then
new_name=$(echo "${new_name%.rom}_${{ inputs.type }}.rom")
fi
fi
# Create release directory if it doesn't exist
$CURL_CMD -X MKCOL "$BASE_URL/$base_dir"
$CURL_CMD -X MKCOL "$BASE_URL/$base_dir/$model"
$CURL_CMD -X MKCOL "$BASE_URL/$base_dir/$model/$release"
# upload firmware and hash files
$CURL_CMD -X PUT -T "artifacts/coreboot.rom" "$BASE_URL/$base_dir/$model/$release/$new_name"
sha256sum artifacts/coreboot.rom > ${new_name}.sha256
$CURL_CMD -X PUT -T "${new_name}.sha256" "$BASE_URL/$base_dir/$model/$release/"