Merge pull request #302 from rohaizanr/api-publish #1
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
name: Publish Saas to Docker Hub | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "saas/**" | |
jobs: | |
build-public-web: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the code | |
uses: actions/checkout@v4 | |
- name: Verify Docker Hub credentials | |
run: | | |
if [[ -z "${{ secrets.DOCKER_USERNAME }}" || -z "${{ secrets.DOCKER_PASSWORD }}" ]]; then | |
echo "Error: Missing Docker Hub credentials"; | |
exit 1; | |
fi | |
- name: Log in to Docker Hub | |
run: | | |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
- name: Build and publish to Docker Hub | |
run: | | |
VERSION=$(git rev-parse HEAD) # Use short commit hash for versioning | |
IMAGE_NAME=dev4w4n/emasjid-public-web:${VERSION} | |
docker build -t emasjid-public-web ./public-web | |
docker tag emasjid-public-web $IMAGE_NAME | |
docker push $IMAGE_NAME |