Parcourir la source

add build to container registry

Aneurin Barker Snook il y a 11 mois
Parent
commit
e502d42351
1 fichiers modifiés avec 44 ajouts et 0 suppressions
  1. 44 0
      .github/workflows/build.yml

+ 44 - 0
.github/workflows/build.yml

@@ -0,0 +1,44 @@
+# Build and publish to GitHub Container Registry
+#
+# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#publishing-a-package-using-an-action
+
+name: Build Docker image
+
+on:
+  workflow_dispatch:
+  push:
+    tags:
+      - v*
+
+env:
+  IMAGE_NAME: ${{ github.repository }}
+  REGISTRY: ghcr.io
+
+jobs:
+  build:
+    name: Build and publish
+    runs-on: ubuntu-latest
+    environment: ${{ inputs.environment }}
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v4
+
+      - name: Log in to registry
+        uses: docker/login-action@v3
+        with:
+          registry: ghcr.io
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Extract image metadata
+        id: meta
+        uses: docker/metadata-action@v5
+        with:
+          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
+
+      - name: Build and push image
+        uses: docker/build-push-action@v5
+        with:
+          labels: ${{ steps.meta.outputs.labels }}
+          push: true
+          tags: ${{ steps.meta.outputs.tags }}