Update Deploy #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: Build & Push coding-service | |
| on: | |
| push: | |
| branches: [ main ] | |
| tags: [ 'v*.*.*' ] | |
| paths: | |
| - 'coding-service/**' | |
| - 'docker/java-service-coding.Dockerfile' | |
| - '.github/workflows/coding-service-publish.yml' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| concurrency: | |
| group: docker-coding-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| ### | |
| build-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-qemu-action@v3 | |
| - uses: docker/setup-buildx-action@v3 | |
| - name: Derive tags (Docker Hub + GHCR) | |
| id: meta | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| OWNER_LC="$(printf '%s' "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')" | |
| if [ "${GITHUB_REF_TYPE}" = "tag" ]; then | |
| TAG="${GITHUB_REF_NAME#v}" | |
| else | |
| TAG="${GITHUB_SHA::12}" | |
| fi | |
| echo "IMAGE_TAG=${TAG}" >> "$GITHUB_ENV" | |
| REPO_HUB="${{ secrets.DOCKERHUB_USER }}/codecampus-${{ matrix.module || 'file-service' }}" | |
| REPO_GHCR="ghcr.io/${OWNER_LC}/codecampus-${{ matrix.module || 'file-service' }}" | |
| HUB="${REPO_HUB}:${TAG}"$'\n'"${REPO_HUB}:latest" | |
| GHCR="${REPO_GHCR}:${TAG}"$'\n'"${REPO_GHCR}:latest" | |
| { | |
| echo "tags<<__TAGS__" | |
| printf '%s\n' "$HUB" | |
| printf '%s\n' "$GHCR" | |
| echo "__TAGS__" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USER }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build & Push coding-service | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: docker/java-service-coding.Dockerfile | |
| build-args: | | |
| MODULE=coding-service | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |