Skip to content

Commit

Permalink
Add script to build docker image and use the same script in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaranvpl committed Sep 28, 2023
1 parent b5390ca commit e3a62ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: Build Docker Image
on:
push:
branches:
- master
- main
- '*'

jobs:
build_docker:
Expand All @@ -21,6 +20,7 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- run: docker build -t ghcr.io/$GITHUB_REPOSITORY:latest .
- run: ./scripts/build_docker.sh $GITHUB_REPOSITORY_OWNER ${{ github.event.repository.name }}
- name: Push built image
run: docker push ghcr.io/$GITHUB_REPOSITORY --all-tags
if: github.ref_name == 'main' || github.ref_name == 'master'
run: docker push ghcr.io/$GITHUB_REPOSITORY_OWNER/${{ github.event.repository.name }} --all-tags
12 changes: 12 additions & 0 deletions scripts/build_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

if [ $# -ne 2 ]; then
echo "Usage: $0 <username> <repo-name>"
exit 1
fi

username="$1"

reponame="$2"

docker build -t ghcr.io/$username/$reponame:latest .

0 comments on commit e3a62ee

Please sign in to comment.