summary history files

commit:b10ce71a79d2dbba467e9acde71ec833a82b389f
date:Thu May 16 07:42:57 2024 +1000
parents:d77f0831e2c36efb5ad607a1da198b3aa7374c67, 1a7eb7ffb18ad5ed5dad33e333053b8875df3f83
Merge pull request #6 from rene00/container-build

improve github build action
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
line changes: +0/-33
index c8d4649..0000000
--- a/.github/workflows/build.yaml
+++ /dev/null
@@ -1,33 +0,0 @@
-name: Build and publish container
-
-on:
-  push:
-    branches:
-      - main
-
-env:
-  IMAGE_NAME: aircon-influx
-  IMAGE_TAG: latest
-  CONTAINER_REGISTRY: ghcr.io
-
-jobs:
-  build-and-publish:
-    runs-on: ubuntu-latest
-
-    steps:
-    - name: Checkout code
-      uses: actions/checkout@v2
-
-    - name: Install Podman
-      run: |
-        sudo apt-get update
-        sudo apt-get -y install podman
-
-    - name: Login to Container Registry
-      run: echo ${{ secrets.GITHUB_TOKEN }} | podman login ${{ env.CONTAINER_REGISTRY }} -u ${{ github.actor }} --password-stdin
-
-    - name: Build container
-      run: podman build -t ${CONTAINER_REGISTRY}/${{ github.repository }}/${IMAGE_NAME}:${IMAGE_TAG} .
-
-    - name: Push container
-      run: podman push ${CONTAINER_REGISTRY}/${{ github.repository }}/${IMAGE_NAME}:${IMAGE_TAG}

diff --git a/.github/workflows/container.yaml b/.github/workflows/container.yaml
line changes: +63/-0
index 0000000..ee5491b
--- /dev/null
+++ b/.github/workflows/container.yaml
@@ -0,0 +1,63 @@
+name: container
+
+on:
+  workflow_dispatch:
+  push:
+    branches:
+      - 'main'
+    tags:
+      - 'v*'
+  pull_request:
+    branches:
+      - 'main'
+
+env:
+  REGISTRY_USER: ${{ github.actor }}
+  REGISTRY_PASSWORD: ${{ github.token }}
+  IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
+
+jobs:
+  build-and-push-image:
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      packages: write
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+        with:
+          fetch-depth: 0
+
+      - name: Docker meta
+        id: docker-metadata
+        uses: docker/metadata-action@v4
+        with:
+          images: ghcr.io/${{ github.actor }}/aircon-influx
+
+      - name: Build Image
+        id: build-image
+        uses: redhat-actions/buildah-build@v2
+        with:
+          image: aircon-influx
+          tags: ${{ steps.docker-metadata.outputs.tags }}
+          labels: ${{ steps.docker-metadata.outputs.labels }}
+          containerfiles: |
+            ./Containerfile
+          extra-args: |
+            --pull
+
+      - name: Log in to the Container Registry
+        uses: docker/login-action@v2
+        with:
+          registry: ghcr.io
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Push to Container Registry
+        uses: redhat-actions/push-to-registry@v2
+        with:
+          image: ${{ steps.build-image.outputs.image }}
+          tags: ${{ steps.build-image.outputs.tags }}
+          registry: ghcr.io/${{ github.actor }}
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}