Skip to content

Merge pull request #104 from KarthikUdyawar/release-1.2 #44

Merge pull request #104 from KarthikUdyawar/release-1.2

Merge pull request #104 from KarthikUdyawar/release-1.2 #44

name: Build and Publish Docker Image to DockerHub
on:
push:
branches: ["main"]
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- name: DockerHub Login
uses: docker/login-action@v2.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/passwordometer-api:1.2.0
secrets: |
"KAGGLE_USERNAME=${{ secrets.KAGGLE_USERNAME }}"
"KAGGLE_KEY=${{ secrets.KAGGLE_KEY }}"
"MONGODB_CONN_STRING=${{ secrets.MONGODB_CONN_STRING }}"
- name: Login to GitHub Container Registry
uses: docker/login-action@v2.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.API_GITHUB_TOKEN }}
- name: Build & Push the Docker image in Github package
run: |
docker build . --tag ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:1.2.0 \
-e KAGGLE_USERNAME=${{ secrets.KAGGLE_USERNAME }} \
-e KAGGLE_KEY=${{ secrets.KAGGLE_KEY }} \
-e MONGODB_CONN_STRING=${{ secrets.MONGODB_CONN_STRING }}
docker push ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:1.2.0
env:
IMAGE_NAME: passwordometer-api
# KAGGLE_USERNAME: ${{ secrets.KAGGLE_USERNAME }}
# KAGGLE_KEY: ${{ secrets.KAGGLE_KEY }}
# MONGODB_CONN_STRING: ${{ secrets.MONGODB_CONN_STRING }}