-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Oskarowski/automate-the-deployment
Init Github Action to build docker image and publish it in DockerHub
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |