Преглед на файлове

pipeline: create tags & labels for container image via docker/metadata-action

Fabian Peter Hammerle преди 3 месеца
родител
ревизия
c3f74a933b
променени са 3 файла, в които са добавени 25 реда и са изтрити 4 реда
  1. 18 2
      .github/workflows/container-image.yml
  2. 5 2
      CHANGELOG.md
  3. 2 0
      README.md

+ 18 - 2
.github/workflows/container-image.yml

@@ -12,12 +12,28 @@ jobs:
     runs-on: ubuntu-22.04
     permissions: {packages: write}
     steps:
+    - id: meta
+      # > "automatic" tag management and OCI Image Format Spec… for labels
+      # https://web.archive.org/web/20250103123053/https://docs.docker.com/build/ci/github-actions/manage-tags-labels/
+      uses: docker/metadata-action@v5
+      with:
+        images: ghcr.io/${{ github.actor }}/systemctl-mqtt
+        # https://web.archive.org/web/20250103130404/https://github.com/docker/metadata-action?tab=readme-ov-file#tags-input
+        tags: |
+          type=semver,pattern={{version}}
+          type=ref,event=branch
+          type=ref,event=pr
+          type=sha,format=long
+          type=raw,value=latest,enable=false
     - uses: docker/setup-qemu-action@v3.2.0
     - uses: docker/login-action@v3
       with:
         registry: ghcr.io
         username: ${{ github.actor }}
         password: ${{ secrets.GITHUB_TOKEN }}
+    # > setup-buildx action … is not required but recommended using it to be
+    # > able to build multi-platform images, export cache, etc.
+    # https://web.archive.org/web/20250103122420/https://github.com/marketplace/actions/build-and-push-docker-images
     - uses: docker/setup-buildx-action@v3.8.0
     # > By default, this action uses the Git context so you don't need to use
     # > the actions/checkout action to checkout the repository because this
@@ -37,5 +53,5 @@ jobs:
           linux/arm/v7
           linux/arm64
         push: true
-        tags: |
-          ghcr.io/${{ github.actor }}/systemctl-mqtt:${{ github.sha }}-attempt${{ github.run_attempt }}
+        tags: ${{ steps.meta.outputs.tags }}
+        labels: ${{ steps.meta.outputs.labels }}

+ 5 - 2
CHANGELOG.md

@@ -64,8 +64,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - compatibility with `python3.5`, `python3.6`, `python3.7` & `python3.8`
 
 ### Internal
-- pipeline: build container image for armv6 & arm64 (in addition to amd64 & armv7)
-- pipeline: push container images to ghcr.io
+- pipeline:
+  - build container image for armv6 & arm64 (in addition to amd64 & armv7)
+  - push container images to ghcr.io
+  - create tags & labels for container image via
+    [docker/metadata-action](https://github.com/docker/metadata-action)
 
 ## [0.5.0] - 2020-11-06
 ### Added

+ 2 - 0
README.md

@@ -71,6 +71,8 @@ added automatically:
 - `button.[hostname]_logind_lock_all_sessions`
 - `button.[hostname]_logind_poweroff`
 - `button.[hostname]_logind_suspend`
+- `sensor.[hostname]_unit_system_[unit_name]_active_state`
+  for `--monitor-system-unit [unit_name]`
 
 ![homeassistant entities_over_auto_discovery](docs/homeassistant/entities-after-auto-discovery.png)