From 03227e5f1083251fe441d6a1ff51dc1fec4197f5 Mon Sep 17 00:00:00 2001 From: Oskarowski Date: Tue, 10 Sep 2024 19:28:28 +0000 Subject: [PATCH] init docker image build and push --- .github/workflows/docker-publish.yaml | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/docker-publish.yaml diff --git a/.github/workflows/docker-publish.yaml b/.github/workflows/docker-publish.yaml new file mode 100644 index 0000000..5745fe8 --- /dev/null +++ b/.github/workflows/docker-publish.yaml @@ -0,0 +1,36 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - master + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + + steps: + # Checkout the repository + - name: Checkout code + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + run: | + docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_HUB_TOKEN }} + + # Docker build + - name: Docker build + run: | + IMAGE_NAME=oskarowskii/minesweeper-golang-htmx + COMMIT_SHA=${{ github.sha }} + + docker build -t $IMAGE_NAME:latest -t $IMAGE_NAME:$COMMIT_SHA . + + # Push to Docker Hub + - name: Push to Docker Hub + run: | + IMAGE_NAME=oskarowskii/minesweeper-golang-htmx + COMMIT_SHA=${{ github.sha }} + + docker push $IMAGE_NAME:latest + docker push $IMAGE_NAME:$COMMIT_SHA