diff --git a/.github/docker-build-and-push.yml b/.github/docker-build-and-push.yml deleted file mode 100644 index c321b2b..0000000 --- a/.github/docker-build-and-push.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Build and Push Docker Image - -on: - push: - branches: - - adv-docker-example - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Log in to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GHCR_TOKEN }} - - - name: Build and push Docker image - uses: docker/build-push-action@v3 - with: - context: . - push: true - tags: ghcr.io/${{ github.repository_owner }}/hello-docker:latest diff --git a/.github/workflows/docker-build-and-push.yml b/.github/workflows/docker-build-and-push.yml new file mode 100644 index 0000000..76cfe4b --- /dev/null +++ b/.github/workflows/docker-build-and-push.yml @@ -0,0 +1,39 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - adv-docker-example + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/${{ github.repository }} + tags: latest + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: "./solutions/hello-docker" + file: "./solutions/hello-docker/Dockerfile.production" + push: true + tags: ${{ steps.meta.outputs.tags }}