Merge pull request #308 from rohaizanr:fix-saas-publish #30
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 API to Docker Hub | |
on: | |
push: | |
branches: | |
- main | |
# Listen on all paths under the "api" directory except for api/core | |
paths: | |
- "api/**" | |
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 |