-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Pawel Langowski <[email protected]>
- Loading branch information
1 parent
c3e6510
commit d97b1de
Showing
2 changed files
with
126 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
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 | ||
|
||
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 }} | ||
if [ "${{ inputs.platform }}" == "protectli" ]; then | ||
base_dir="protectli" | ||
model=$(echo "$tag" | cut -d'_' -f1-3) | ||
release=$(echo "$tag" | cut -d'_' -f4) | ||
elif [ "${{ inputs.platform }}" == "novacustom" ]; then | ||
base_dir="novacustom" | ||
model=$(echo "$tag" | cut -d'_' -f1-3) | ||
release=$(echo "$tag" | cut -d'_' -f4) | ||
elif [ "${{ inputs.platform }}" == "pcengines" ]; then | ||
base_dir="pcengines" | ||
model="pcengines_apu2" | ||
release=$(echo "$tag" | cut -d'_' -f3) | ||
elif [ "${{ inputs.platform }}" == "msi" ]; then | ||
base_dir="msi" | ||
model=$(echo "$tag" | cut -d'_' -f1-2) | ||
release=$(echo "$tag" | cut -d'_' -f3) | ||
fi | ||
echo "base_dir=$base_dir" >> "$GITHUB_OUTPUT" | ||
echo "model=$model" >> "$GITHUB_OUTPUT" | ||
echo "release=$release" >> "$GITHUB_OUTPUT" | ||
- name: Parse artifact name | ||
id: artifact_name | ||
run: | | ||
if [ "${{ inputs.platform }}" == "protectli" ]; then | ||
echo "dasharo-${{ inputs.vendor }}-${{ inputs.model }}" >> "$GITHUB_OUTPUT" | ||
elif [ "${{ inputs.platform }}" == "novacustom" ]; then | ||
first_part=$(echo ${{ steps.tag_name.outputs.tag }} | cut -d "_" -f1) | ||
second_part=$(echo ${{ steps.tag_name.outputs.tag }} | cut -d "_" -f2-3) | ||
echo "artifact_name=dasharo-$first_part-$second_part" >> "$GITHUB_OUTPUT" | ||
elif [ "${{ inputs.platform }}" == "pcengines" ]; then | ||
echo "dasharo-${{ inputs.vendor }}-${{ inputs.model }}-${{ inputs.payload }}" >> "$GITHUB_OUTPUT" | ||
elif [ "${{ inputs.platform }}" == "msi" ]; then | ||
first_part=$(echo ${{ steps.tag_name.outputs.tag }} | cut -d "_" -f1) | ||
second_part=$(echo ${{ steps.tag_name.outputs.tag }} | cut -d "_" -f2) | ||
echo "artifact_name=dasharo-$first_part-${second_part}_${{ inputs.type }}" >> "$GITHUB_OUTPUT" | ||
fi | ||
# Allows downloading artifacts from a different workflow | ||
- name: Download workflow artifact | ||
uses: dawidd6/action-download-artifact@v6 | ||
with: | ||
workflow: build.yml | ||
name: ${{ steps.artifact_name.outputs.artifact_name }} | ||
path: "./artifacts" | ||
|
||
- name: Upload to Nextcloud | ||
env: | ||
CLOUD_URL: ${{ secrets.CLOUD_URL }} | ||
CLOUD_PASSWORD: ${{ secrets.CLOUD_PASSWORD }} | ||
run: | | ||
BASE_URL="https://cloud.3mdeb.com/public.php/webdav" | ||
url_part=$(echo "$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 }}" | ||
artifact_name="${{ steps.artifact_name.outputs.artifact_name }}" | ||
CURL_CMD="curl -u $url_part:$CLOUD_PASSWORD" | ||
if [ "${{ inputs.platform }}" == "protectli" ]; then | ||
new_name=$(echo "${{ inputs.vendor }}-${{ inputs.model }}.rom" | sed 's/-/_/g; s/.*/\L&/') | ||
elif [ "${{ inputs.platform }}" == "novacustom" ]; then | ||
new_name=$(echo "${model}_${release}.rom" | sed 's/-/_/g; s/.*/\L&/') | ||
elif [ "${{ inputs.platform }}" == "pcengines" ]; then | ||
new_name=$(echo "${{ inputs.vendor }}_${{ inputs.model }}_${{ inputs.payload }}_${release}.rom" | sed 's/.*/\L&/') | ||
elif [ "${{ inputs.platform }}" == "msi" ]; then | ||
new_name=$(echo "${model}_${{ inputs.type }}_${release}.rom" | sed 's/-/_/g; s/.*/\L&/') | ||
fi | ||
# Create release directory if it doesn't exist | ||
$CURL_CMD -X MKCOL "$BASE_URL/$base_dir/$model/$release" | ||
$CURL_CMD -X PUT -T "artifacts/$artifact_name/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/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters