From 3ea9e49bf1e1d944843c5aa1a487032254d46e18 Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 11 Apr 2024 16:43:25 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20gh=20action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-image.yml | 43 +++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 3d8a3b8..abdd884 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -4,13 +4,44 @@ on: push: branches: [ "main", "dev" ] -jobs: - - build: +env: + REGISTRY: ghcr.io/vngcloud +jobs: + build-and-push-image: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - image: vngcloud-ingress-controller + - image: vngcloud-controller-manager + permissions: + contents: read + packages: write steps: - - uses: actions/checkout@v3 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GH_PACKAGE_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ matrix.image }} + tags: latest + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + target: ${{ matrix.image }}