Skip to content

Commit

Permalink
Merge pull request #3 from Oskarowski/automate-the-deployment
Browse files Browse the repository at this point in the history
Init Github Action to build docker image and publish it in DockerHub
  • Loading branch information
Oskarowski authored Sep 10, 2024
2 parents 059bf0b + 03227e5 commit fa67b80
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fa67b80

Please sign in to comment.