Skip to content

Commit

Permalink
enable cicd
Browse files Browse the repository at this point in the history
  • Loading branch information
ragibkl committed Dec 22, 2023
1 parent 7dde856 commit 96cc195
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Bancuh DNS Docker Image CI

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push the Docker image
run: ./scripts/build.sh
working-directory: ./
1 change: 1 addition & 0 deletions scripts/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
24 changes: 24 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
WORKDIR="$SCRIPT_DIR"/..

BRANCH=$(git describe --tags --exact-match 2> /dev/null \
|| git symbolic-ref -q --short HEAD \
|| git rev-parse --short HEAD)

TAG=latest
if [ "$BRANCH" != master ]
then
TAG=$BRANCH
fi

REGISTRY_TAG="ragibkl/bancuh_dns:$TAG"
echo "WORKDIR=$WORKDIR"
echo "BRANCH=$BRANCH"
echo "TAG=$TAG"
echo "REGISTRY_TAG=$REGISTRY_TAG"

cd $WORKDIR
docker build --pull -t $REGISTRY_TAG -f ./Dockerfile .
docker push $REGISTRY_TAG

0 comments on commit 96cc195

Please sign in to comment.