refactor: rework light scenes trigger #438
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: CD | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: bdossantos | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Extract Dockefile build context, image name and tags | |
shell: bash | |
id: context | |
run: | | |
version=$(egrep ' VERSION=(.*)$' 'Dockerfile' | sed 's/^.*=//') | |
vcs_ref=$(git rev-parse --short HEAD) | |
image_name='home-assistant' | |
tags=bdossantos/${image_name}:latest,bdossantos/${image_name}:${version},bdossantos/${image_name}:${version}-${vcs_ref} | |
echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
echo "path=$(dirname ${{ inputs.dockerfile }})" >> $GITHUB_OUTPUT | |
echo "tags=${tags}" >> $GITHUB_OUTPUT | |
echo "vcs_ref=${vcs_ref}" >> $GITHUB_OUTPUT | |
- name: Build and push docker image | |
uses: docker/build-push-action@v6 | |
with: | |
build-args: | | |
BUILD_DATE=${{ steps.context.outputs.build_date }} | |
VCS_REF=${{ steps.context.outputs.vcs_ref }} | |
context: ${{ steps.context.outputs.path }} | |
file: Dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.context.outputs.tags }} |