Skip to content

Commit

Permalink
wip: reusable workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Langowski <[email protected]>
  • Loading branch information
PLangowski committed Jul 17, 2024
1 parent c3e6510 commit 1c5ed7f
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 211 deletions.
107 changes: 107 additions & 0 deletions .github/workflows/deploy-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
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 "artifact_name=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 "artifact_name=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 }}"
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/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/"
229 changes: 18 additions & 211 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,236 +6,43 @@ on:

jobs:
deploy_protectli:
runs-on: ubuntu-22.04
if: contains(github.ref, 'refs/tags/protectli')
uses: ./.github/workflows/deploy-template.yml
with:
platform: protectli
vendor: ${{ matrix.vendor }}
model: ${{ matrix.model }}
strategy:
matrix:
vendor: [ protectli ]
model: [ vp66xx, vp46xx, vp2420, vp2410, V1210, V1211, V1410, V1610 ]
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Checkout all submodules
run: git submodule update --init --recursive --checkout

- name: Set up tag name
id: tag_name
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"

- name: Parse directories from tag
id: parse_directories
run: |
tag=${{ steps.tag_name.outputs.tag }}
base_dir="protectli"
model=$(echo "$tag" | cut -d'_' -f1-3)
release=$(echo "$tag" | cut -d'_' -f4)
echo "base_dir=$base_dir" >> "$GITHUB_OUTPUT"
echo "model=$model" >> "$GITHUB_OUTPUT"
echo "release=$release" >> "$GITHUB_OUTPUT"
# Allows downloading artifacts from a different workflow
- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v6
with:
workflow: build.yml
name: "dasharo-${{ matrix.vendor }}-${{ matrix.model }}"
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 }}"
CURL_CMD="curl -u $url_part:$CLOUD_PASSWORD"
new_name=$(echo "${{ matrix.vendor }}-${{ matrix.model }}.rom" | sed 's/-/_/g; s/.*/\L&/')
# Create release directory if it doesn't exist
$CURL_CMD -X MKCOL "$BASE_URL/$base_dir/$model/$release"
$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/"

deploy_novacustom:
runs-on: ubuntu-22.04
if: contains(github.ref, 'refs/tags/novacustom')
uses: ./.github/workflows/deploy-template.yml
with:
platform: novacustom

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Checkout all submodules
run: git submodule update --init --recursive --checkout

- name: Set up tag name
id: tag_name
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"

- name: Parse directories from tag
id: parse_directories
run: |
tag=${{ steps.tag_name.outputs.tag }}
base_dir="novacustom"
model=$(echo "$tag" | cut -d'_' -f1-3)
release=$(echo "$tag" | cut -d'_' -f4)
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: |
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"
# 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 }}"
CURL_CMD="curl -u $url_part:$CLOUD_PASSWORD"
new_name=$(echo "${model}_${release}.rom" | sed 's/-/_/g; s/.*/\L&/')
# Create release directory if it doesn't exist
$CURL_CMD -X MKCOL "$BASE_URL/$base_dir/$model/$release"
$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/"
deploy_pcengines:
runs-on: ubuntu-22.04
if: contains(github.ref, 'refs/tags/pcengines')
uses: ./.github/workflows/deploy-template.yml
with:
platform: pcengines
vendor: ${{ matrix.vendor }}
model: ${{ matrix.model }}
payload: ${{ matrix.payload }}
strategy:
matrix:
vendor: [ pcengines ]
model: [ apu2, apu3, apu4, apu6 ]
payload: [ uefi ]
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Checkout all submodules
run: git submodule update --init --recursive --checkout

- name: Set up tag name
id: tag_name
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"

- name: Parse directories from tag
id: parse_directories
run: |
tag=${{ steps.tag_name.outputs.tag }}
base_dir="pcengines"
release=$(echo "$tag" | cut -d'_' -f3)
echo "base_dir=$base_dir" >> "$GITHUB_OUTPUT"
echo "release=$release" >> "$GITHUB_OUTPUT"
# Allows downloading artifacts from a different workflow
- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v6
with:
workflow: build.yml
name: "dasharo-${{ matrix.vendor }}-${{ matrix.model }}-${{ matrix.payload }}"
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 }}"
release="${{ steps.parse_directories.outputs.release }}"
CURL_CMD="curl -u $url_part:$CLOUD_PASSWORD"
new_name=$(echo "${{ matrix.vendor }}_${{ matrix.model }}_${{ matrix.payload }}_${release}.rom" | sed 's/.*/\L&/')
# Create release directory if it doesn't exist
$CURL_CMD -X MKCOL "$BASE_URL/$base_dir/pcengines_apu2/$release"
$CURL_CMD -X PUT -T "artifacts/coreboot.rom" "$BASE_URL/$base_dir/pcengines_apu2/$release/$new_name"
sha256sum artifacts/coreboot.rom > ${new_name}.sha256
$CURL_CMD -X PUT -T "${new_name}.sha256" "$BASE_URL/$base_dir/pcengines_apu2/$release/"

deploy_msi:
runs-on: ubuntu-22.04
if: contains(github.ref, 'refs/tags/msi')
uses: ./.github/workflows/deploy-template.yml
with:
platform: msi
type: ${{ matrix.type }}
strategy:
matrix:
type: [ ddr4, ddr5 ]
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Checkout all submodules
run: git submodule update --init --recursive --checkout

- name: Set up tag name
id: tag_name
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"

- name: Parse directories from tag
id: parse_directories
run: |
tag=${{ steps.tag_name.outputs.tag }}
base_dir="msi"
model=$(echo "$tag" | cut -d'_' -f1-2)
release=$(echo "$tag" | cut -d'_' -f3)
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: |
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}_${{ matrix.type }}" >> "$GITHUB_OUTPUT"
# 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 }}"
CURL_CMD="curl -u $url_part:$CLOUD_PASSWORD"
new_name=$(echo "${model}_${{ matrix.type }}_${release}.rom" | sed 's/-/_/g; s/.*/\L&/')
# Create release directory if it doesn't exist
$CURL_CMD -X MKCOL "$BASE_URL/$base_dir/$model/$release"
$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/"

0 comments on commit 1c5ed7f

Please sign in to comment.