Skip to content

Commit

Permalink
feat: Add workflow to build docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
benzino77 committed Jan 7, 2024
1 parent 91cc9f3 commit b881603
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/build-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Build Docker Image
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to build from'
required: true
default: 'master'
options:
- 'master'
- 'development'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.branch }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq

- name: Load Buildx
run: docker buildx create --name mybuilder --use
if: runner.os == 'Linux'

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}

- name: Extract version from package.json
if: ${{ github.event.inputs.branch }} != 'development'
run: echo "DOCKER_TAG=$(jq -r '.version' package.json)" >> $GITHUB_ENV

- name: Build and push production Docker image
if: ${{ github.event.inputs.branch }} != 'development'
run: |
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
-t benzino77/tasmocompiler:$DOCKER_TAG \
-t benzino77/tasmocompiler:latest \
-f Dockerfile .
- name: Build and push development Docker image
if: ${{ github.event.inputs.branch }} != 'development'
run: |
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
-t benzino77/tasmocompiler:development \
-f Dockerfile .

0 comments on commit b881603

Please sign in to comment.