Publish Docker image #4
This file contains hidden or 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: Publish Docker image | |
on: | |
workflow_dispatch: | |
push: | |
paths: | |
- 'pubspec.*' | |
- 'src/**' | |
- 'Dockerfile' | |
- '.github/workflows/**' | |
branches: | |
- main | |
jobs: | |
push_to_registry: | |
name: Push Docker image to Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Log in to Docker Hub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUBUSERNAME }} | |
password: ${{ secrets.DOCKERHUBACCESSTOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 | |
with: | |
images: ${{ secrets.DOCKERHUBUSERNAME }}/leaf2mqtt | |
tags: | | |
type=raw,value=${{ github.run_number }} | |
type=raw,value=latest | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
platforms: linux/amd64,linux/arm64,linux/arm/v8 | |
tags: ${{ steps.meta.outputs.tags }} | |
update_addon: | |
name: Update Home Assistant add-on | |
needs: push_to_registry | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Change image version number | |
uses: jossef/action-set-json-field@v1 | |
with: | |
file: addon/config.json | |
field: version | |
value: ${{ github.run_number }} | |
- name: Commit changes | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: Update add-on version |