Merge pull request #196 from CapstoneProjectCMC/feature/ulr-user-lear… #18
This file contains hidden or 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: Frontend Docker Publish | |
| on: | |
| push: | |
| branches: ["main"] | |
| tags: ["v*.*.*"] | |
| paths: | |
| - "src/**" | |
| - "angular.json" | |
| - "package.json" | |
| - "package-lock.json" | |
| - "docker/angular-frontend.Dockerfile" | |
| - "docker/nginx.conf" | |
| - ".github/workflows/frontend-docker-publish.yml" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| DOCKER_REPO: ${{ secrets.DOCKERHUB_USER }}/codecampus-frontend | |
| DOCKERFILE_PATH: docker/angular-frontend.Dockerfile | |
| PLATFORMS: linux/amd64 | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Derive tags | |
| id: meta | |
| run: | | |
| TAGS="" | |
| if [ "${GITHUB_REF_TYPE}" = "tag" ]; then | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| echo "IMAGE_TAG=${VERSION}" >> $GITHUB_ENV | |
| TAGS="${{ env.DOCKER_REPO }}:${VERSION}" | |
| else | |
| SHA_TAG="${GITHUB_SHA::12}" | |
| echo "IMAGE_TAG=${SHA_TAG}" >> $GITHUB_ENV | |
| TAGS="${{ env.DOCKER_REPO }}:${SHA_TAG}" | |
| if [ "${GITHUB_REF_NAME}" = "main" ]; then | |
| TAGS="${TAGS},${{ env.DOCKER_REPO }}:latest" | |
| fi | |
| fi | |
| echo "tags=${TAGS}" >> $GITHUB_OUTPUT | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USER }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build & Push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ${{ env.DOCKERFILE_PATH }} | |
| platforms: ${{ env.PLATFORMS }} | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |