v4.0.5 #117
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
# This is a basic workflow to help you get started with Actions | |
name: Docker Build | |
# Controls when the action will run. | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
required: true | |
type: string | |
description: "Version" | |
release: | |
types: [published] | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a 2 jobs called "alpine" and "debian" | |
alpine: | |
env: | |
# Setting the defaults up front | |
LATEST_NODE: 20 | |
DEFAULT_IMAGE: nodered/node-red | |
DEV_IMAGE: nodered/node-red-dev | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 2 | |
matrix: | |
node: [18, 20, 22] | |
suffix: ["", "-minimal"] | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
- | |
name: Checkout | |
uses: actions/[email protected] | |
- name: Show Env | |
run: env | |
- | |
name: Docker Metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
flavor: | | |
latest=false | |
suffix=-${{matrix.node}}${{matrix.suffix}} | |
images: | | |
${{ env.DEFAULT_IMAGE }} | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern={{version}} | |
- | |
name: Setup QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64 | |
- | |
name: Set up SSH key pi5 | |
uses: MrSquaare/ssh-setup-action@2d028b70b5e397cf8314c6eaea229a6c3e34977a # v3.1.0 | |
with: | |
host: ${{ secrets.SSH_REMOTE_HOST}} | |
private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
private-key-name: remote | |
port: 2022 | |
- | |
name: Set up SSH key pi4 | |
uses: MrSquaare/ssh-setup-action@2d028b70b5e397cf8314c6eaea229a6c3e34977a # v3.1.0 | |
with: | |
host: ${{ secrets.SSH_REMOTE_HOST}} | |
private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
private-key-name: remote | |
port: 2023 | |
- | |
name: Setup Docker buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
append: | | |
- endpoint: ssh://nr@${{ secrets.SSH_REMOTE_HOST }}:2023 | |
platforms: linux/arm/v6,linux/arm/v7 | |
- endpoint: ssh://nr@${{ secrets.SSH_REMOTE_HOST }}:2022 | |
platforms: linux/arm64 | |
- name: Get Date | |
id: date | |
# run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H:%M:%SZ')" | |
run: echo "date=$(date +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
- name: Get Node-RED Version | |
id: nrVersion | |
run: | | |
TAGS="" | |
while IFS= read -r TAG;do | |
if [ -z "$TAGS" ]; then | |
TAGS=$TAG | |
else | |
TAGS="$TAGS,$TAG" | |
fi | |
done <<< "${{ steps.meta.outputs.tags }}" | |
echo "Start Tags = $TAGS" | |
echo "GITHUB_REF = $GITHUB_REF" | |
echo "version = ${{ github.event.inputs.version }}" | |
if [[ ! -z "${{ github.event.inputs.version }}" ]]; then | |
TEMP=${{ github.event.inputs.version }} | |
TEMP=${TEMP:1} | |
TEMP2=$(echo $GITHUB_REF | awk -F '/' '{ print $3}') | |
echo "$GITHUB_REF - $TEMP" | |
TAGS=$(echo $TAGS | sed "s/$TEMP2/$TEMP/") | |
TRAVIS_TAG=${{ github.event.inputs.version }} | |
else | |
TRAVIS_TAG=$(echo $GITHUB_REF | awk -F '/' '{ print $3}') | |
fi | |
echo "TRAVIS_TAG = $TRAVIS_TAG" | |
if [[ "$TRAVIS_TAG" =~ ^v[0-9\.-]*$ ]]; then | |
IMAGE=${{ env.DEFAULT_IMAGE }} | |
PUSH=true | |
VERSION=${TRAVIS_TAG:1} | |
STABLE_VERSION=`echo ${VERSION} | sed -r 's/^([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)$/\1.\2/'` | |
if [[ "${{ matrix.node }}" == "${{ env.LATEST_NODE }}" && "${{ matrix.suffix }}" == "" ]]; then | |
TAGS="$TAGS,$IMAGE:$VERSION,$IMAGE:$STABLE_VERSION,$IMAGE:latest" | |
elif [[ "${{ matrix.node }}" == "${{ env.LATEST_NODE }}" && "${{ matrix.suffix }}" == "-minimal" ]]; then | |
TAGS="$TAGS,$IMAGE:$VERSION-minimal,$IMAGE:latest-minimal" | |
fi | |
TAGS="$TAGS,$IMAGE:latest-${{ matrix.node }}${{ matrix.suffix }}" | |
else | |
IMAGE=${{ env.DEV_IMAGE }} | |
if [[ "$TRAVIS_TAG" == *"dev"* || "$TRAVIS_TAG" == *"beta"* ]]; then | |
PUSH=true | |
else | |
PUSH=false | |
fi | |
VERSION=${TRAVIS_TAG} | |
TAGS=$(echo $TAGS | sed 's!${{ env.DEFAULT_IMAGE}}!${{ env.DEV_IMAGE }}!') | |
if [ "${{ matrix.node }}" == "${{ env.LATEST_NODE }}" ] && [ "${{ matrix.suffix}}" == "" ]; then | |
TAGS="$TAGS,$IMAGE:$VERSION" | |
fi | |
fi | |
# if [[ "${{ matrix.node }}" == "18"]]; then | |
# echo "platforms=linux/amd64,linux/arm/v7,linux/arm64" >> $GITHUB_OUTPUT | |
# else | |
# echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT | |
# fi | |
# if [[ "${{ matrix.suffix }}" == "-minimal" ]]; then | |
# echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT | |
# else | |
# echo "platforms=linux/amd64,linux/arm/v7,linux/arm64" >> $GITHUB_OUTPUT | |
# fi | |
echo "platforms=linux/amd64,linux/arm/v7,linux/arm64" >> $GITHUB_OUTPUT | |
echo $TAGS | |
echo "tags=$TAGS" >> $GITHUB_OUTPUT | |
echo "push=$PUSH" >> $GITHUB_OUTPUT | |
echo "version=$TRAVIS_TAG" >> $GITHUB_OUTPUT | |
echo "buildVersion=$VERSION" >> $GITHUB_OUTPUT | |
cat $GITHUB_OUTPUT | |
# echo "::set-output name=tags::$TAGS" | |
# echo "::set-output name=push::$PUSH" | |
# echo "::set-output name=version::$TRAVIS_TAG" | |
# echo "::set-output name=buildVersion::$VERSION" | |
- | |
name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- | |
name: Build and push | |
id: build-push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ steps.nrVersion.outputs.platforms }} | |
push: ${{ steps.nrVersion.outputs.push }} | |
file: .docker/Dockerfile.alpine | |
build-args: | | |
NODE_VERSION=${{ matrix.node }} | |
BUILD_DATE=${{ steps.date.outputs.date }} | |
BUILD_VERSION=${{ steps.nrVersion.outputs.buildVersion }} | |
BUILD_REF=${{ env.GITHUB_SHA }} | |
NODE_RED_VERSION=${{ steps.nrVersion.outputs.version }} | |
TAG_SUFFIX=${{ matrix.suffix }} | |
tags: ${{ steps.nrVersion.outputs.tags }} | |
debian: | |
env: | |
# Setting the defaults up front | |
LATEST_NODE: 20 | |
DEFAULT_IMAGE: nodered/node-red | |
DEV_IMAGE: nodered/node-red-dev | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Setup Docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Get Date | |
id: date | |
# run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H:%M:%SZ')" | |
run : echo "date=$(date +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
- name: Docker Metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
flavor: | | |
latest=false | |
images: | | |
${{ env.DEFAULT_IMAGE }} | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern={{version}} | |
- name: Get Node-RED Version | |
id: nrVersion | |
run: | | |
TAGS="" | |
echo Original tags ${{ steps.meta.outputs.tags }} | |
if [[ ! -z "${{ github.event.inputs.version }}" ]]; then | |
TRAVIS_TAG=${{ github.event.inputs.version }} | |
else | |
TRAVIS_TAG=$(echo $GITHUB_REF | awk -F '/' '{ print $3}') | |
fi | |
if [[ "$TRAVIS_TAG" =~ ^v[0-9\.-]*$ ]]; then | |
# release build | |
IMAGE=${{ env.DEFAULT_IMAGE }} | |
PUSH=true | |
VERSION=${TRAVIS_TAG:1} | |
STABLE_VERSION=`echo ${VERSION} | sed -r 's/^([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)$/\1.\2/'` | |
TAGS="$IMAGE:latest-debian,$IMAGE:$VERSION-debian,$IMAGE:$STABLE_VERSION-debian" | |
else | |
IMAGE=${{ env.DEV_IMAGE }} | |
if [[ "$TRAVIS_TAG" == *"dev"* || "$TRAVIS_TAG" == *"beta"* ]]; then | |
# beta build | |
PUSH=true | |
else | |
PUSH=false | |
fi | |
VERSION=${TRAVIS_TAG} | |
TAGS="$IMAGE:$VERSION-debian" | |
fi | |
echo $TAGS | |
echo "tags=$TAGS" >> $GITHUB_OUTPUT | |
echo "push=$PUSH" >> $GITHUB_OUTPUT | |
echo "version=$TRAVIS_TAG" >> $GITHUB_OUTPUT | |
echo "buildVersion=$VERSION" >> $GITHUB_OUTPUT | |
cat $GITHUB_OUTPUT | |
- name: Build and push | |
id: build-push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64, linux/arm64, linux/arm/v7 | |
file: .docker/Dockerfile.debian | |
push: ${{ steps.nrVersion.outputs.push }} | |
build-args: | | |
NODE_VERSION=${{ env.LATEST_NODE }} | |
BUILD_DATE=${{ steps.date.outputs.date }} | |
BUILD_REF=${{ env.GITHUB.SHA }} | |
TAG_SUFFIX=-debian | |
NODE_RED_VERSION=${{ steps.nrVersion.outputs.version }} | |
BUILD_VERSION=${{ steps.nrVersion.outputs.buildVersion }} | |
tags: ${{ steps.nrVersion.outputs.tags }} | |