Skip to content

Merge pull request #3 from Oskarowski/automate-the-deployment #1

Merge pull request #3 from Oskarowski/automate-the-deployment

Merge pull request #3 from Oskarowski/automate-the-deployment #1

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