Skip to content

Commit

Permalink
add container-build-and-push CI step
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <[email protected]>
  • Loading branch information
onur-ozkan committed May 27, 2024
1 parent 0cadc19 commit 71f7ceb
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build-and-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,30 @@ jobs:

- name: Install
run: make install

container-build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Calculate commit hash for PR commit
if: github.event_name == 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 ${{ github.event.pull_request.head.sha }})" >> $GITHUB_ENV

- name: Calculate commit hash for merge commit
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Login to dockerhub
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
run: docker login --username ${{ secrets.DOCKER_HUB_USERNAME }} --password ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} docker.io

- name: Build and Push
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
run: |
docker build -t komodoofficial/nucleusd:"$COMMIT_HASH" -t komodoofficial/nucleusd:latest -f ./Dockerfile
# Here we push two images. "latest" image gets overridden with each
# push and $COMMIT_HASH is a constant image so we can use a specific
# build in container environments if needed (usually for debugging purposes).
docker push komodoofficial/nucleusd:"$COMMIT_HASH"
docker push komodoofficial/nucleusd:latest

0 comments on commit 71f7ceb

Please sign in to comment.