Add error handling to the node-red node #9
Workflow file for this run
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
name: Docker Image CI | |
on: | |
push: | |
tags: | |
- "v*" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Infer the version from the github ref | |
id: inferVersion | |
run: | | |
prefix="refs/tags/v" | |
if [[ ! "${GITHUB_REF}" == ${prefix}* ]]; then | |
echo "Unexpected GITHUB_REF: ${GITHUB_REF}" | |
exit 1 | |
fi | |
version="${GITHUB_REF:${#prefix}}" | |
echo "The version is: ${version}" | |
if [[ "${version}" == *"'"* ]]; then | |
echo "Unexpected version containing a single quote: ${version}" | |
exit 1 | |
fi | |
if [[ "${version}" == *'"'* ]]; then | |
echo "Unexpected version containing a double quote: ${version}" | |
exit 1 | |
fi | |
if [[ "${version}" == *':'* ]]; then | |
echo "Unexpected version containing a full colon: ${version}" | |
exit 1 | |
fi | |
echo "::set-output name=version::${version}" | |
- uses: actions/checkout@v4 | |
- name: Build the Docker image | |
run: | | |
cd capability-check-node-red | |
docker build -t capability-check-node-red:v${{ steps.inferVersion.outputs.version }} -f Dockerfile .. | |
- name: Export the Docker image | |
run: docker save -o capability-check-node-red_v${{ steps.inferVersion.outputs.version }}.tar capability-check-node-red:v${{ steps.inferVersion.outputs.version }} | |
- name: Move to release dir | |
run: | | |
version="${{ steps.inferVersion.outputs.version }}" | |
releaseDir="$(pwd)/artefacts/release/$version" | |
if [ ! -d "$releaseDir" ]; then | |
echo "Creating release directory: $releaseDir" | |
mkdir -p "$releaseDir" | |
fi | |
if [ ! -d "$releaseDir" ]; then | |
mkdir -p "$releaseDir" | |
fi | |
tarName="capability-check-node-red_v$version.tar" | |
echo "Release tar name: $tarName" | |
target="$releaseDir/$tarName" | |
echo "Moving $tarName to $target" | |
mv "capability-check-node-red_v$version.tar" "$target" | |
- name: Check | |
run: | | |
ls artefacts/release | |
ls artefacts/release/${{ steps.inferVersion.outputs.version }} | |
path="artefacts/release/${{ steps.inferVersion.outputs.version }}/capability-check-node-red_v${{ steps.inferVersion.outputs.version }}.tar" | |
if [ ! -f "$path" ]; then | |
echo "The file $path does not exist" | |
exit 1 | |
fi | |
- name: Upload the release assets | |
uses: Hs1r1us/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "v${{ steps.inferVersion.outputs.version }}" | |
asset_files: "artefacts/release/${{ steps.inferVersion.outputs.version }}/capability-check-node-red_v${{ steps.inferVersion.outputs.version }}.tar" |