From 2edc63c692d2136fae801f17948a6efd09b500b4 Mon Sep 17 00:00:00 2001 From: eric Liu Date: Thu, 13 Jun 2024 05:21:47 +0000 Subject: [PATCH] Update .github/workflows/build.yml --- .github/workflows/build.yml | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 031f8f5..3d72895 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,14 +1,26 @@ -name: Build -on: [push, pull_request] +name: Build and Push Docker Image + +on: + push: + branches: + - main + jobs: build: - name: Build runs-on: ubuntu-latest + + env: + IMAGE_NAME: ${{ github.repository_owner }}/${{ github.event.repository.name }} + steps: - - uses: actions/checkout@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Build - uses: docker/build-push-action@v3 - with: - push: false + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Log in to the Docker registry + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login ${{ secrets.DOCKER_REGISTRY }} -u ${{ secrets.DOCKER_USERNAME }} --password-stdin + + - name: Build the Docker image + run: docker build -t ${{ secrets.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest . + + - name: Push the Docker image + run: docker push ${{ secrets.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest \ No newline at end of file