From a7d745a218d1acf5353414f906e2b6578cc5873e Mon Sep 17 00:00:00 2001 From: Juansecu Date: Wed, 8 May 2024 18:52:27 -0500 Subject: [PATCH] CD - Add GitHub Action to push Docker image to Docker Hub --- .github/workflows/push-docker-image.yml | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/push-docker-image.yml diff --git a/.github/workflows/push-docker-image.yml b/.github/workflows/push-docker-image.yml new file mode 100644 index 0000000..5ac3592 --- /dev/null +++ b/.github/workflows/push-docker-image.yml @@ -0,0 +1,32 @@ +name: Push Docker Image + +on: + release: + types: [published] + +jobs: + push-docker-image: + name: Push Docker Image + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + - name: Retrieve major version + uses: winterjung/split@v2 + id: split + with: + msg: ${{ github.ref_name }} + separator: . + - name: Log in to registry + uses: docker/login-action@v3 + with: + password: ${{ secrets.DOCKERHUB_TOKEN }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + - name: Build and push the Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKERHUB_REPOSITORY }}:${{ github.ref_name }},${{ secrets.DOCKERHUB_REPOSITORY }}:${{ steps.split.outputs._0 }},${{ secrets.DOCKERHUB_REPOSITORY }}:latest