Skip to content

Build and Release Images #180

Build and Release Images

Build and Release Images #180

Workflow file for this run

name: Build and Release Images
on:
push:
branches:
- main
paths:
- .arg
workflow_dispatch:
inputs:
build-target:
description: Build Target
required: true
default: "+test"
type: choice
options:
- "+test"
- "+all"
zwave-js-version:
description: Z-Wave JS version
required: true
zwave-js-server-version:
description: Z-Wave JS Server version
required: true
npm-install-flags:
description: Extra `npm install` flags
required: false
type: string
push:
description: Push image to registries
required: true
default: false
type: boolean
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Install earthly
uses: earthly/actions-setup@v1.0.4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout repository
uses: actions/checkout@v3
- name: Set workflow dispatch environment
if: github.event_name == 'workflow_dispatch'
run: |
zjsver=${{ github.event.inputs.zwave-js-version }}
zjssver=${{ github.event.inputs.zwave-js-server-version }}
npmflags=${{ github.event.inputs.npm-install-flags }}
printf 'EARTHLY_BUILD_ARGS=ZWAVE_JS_VERSION=%s,ZWAVE_JS_SERVER_VERSION=%s,NPM_INSTALL_EXTRA_FLAGS=%s\n' "${zjsver}" "${zjssver}" "${npmflags}" >> "${GITHUB_ENV}"
printf 'target=%s\n' "${{ github.event.inputs.build-target }}" >> "${GITHUB_ENV}"
- name: Set release environment
if: github.event_name == 'push'
run: |
printf 'target=+all\n' >> $GITHUB_ENV
- name: Build Images
run: earthly --ci ${{ env.target }}
- name: Push to Docker Hub
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push == 'true')
run: earthly --ci --push ${{ env.target }}
- name: Push to GitHub Container Registry
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push == 'true')
run: earthly --ci --push ${{ env.target }} --REGISTRY=ghcr.io