Docker Publish #5
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: Docker Publish | |
| on: | |
| release: | |
| types: | |
| - published | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: Version tag to publish without the leading v | |
| required: false | |
| type: string | |
| push_latest: | |
| description: Also publish the latest tag | |
| required: true | |
| default: true | |
| type: boolean | |
| permissions: | |
| contents: read | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Resolve publish version | |
| id: release_meta | |
| run: | | |
| if [ "${{ github.event_name }}" = "release" ]; then | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| PUSH_LATEST="true" | |
| else | |
| VERSION="${{ inputs.version }}" | |
| PUSH_LATEST="${{ inputs.push_latest }}" | |
| if [ -z "$VERSION" ]; then | |
| VERSION="$(cat VERSION)" | |
| fi | |
| fi | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "push_latest=$PUSH_LATEST" >> "$GITHUB_OUTPUT" | |
| - name: Prepare Docker tags | |
| id: docker_tags | |
| run: | | |
| BACKEND_TAGS="winlp4ever/dim0-backend:${{ steps.release_meta.outputs.version }}" | |
| WEBUI_TAGS="winlp4ever/dim0-webui:${{ steps.release_meta.outputs.version }}" | |
| if [ "${{ steps.release_meta.outputs.push_latest }}" = "true" ]; then | |
| BACKEND_TAGS="${BACKEND_TAGS}"$'\n'"winlp4ever/dim0-backend:latest" | |
| WEBUI_TAGS="${WEBUI_TAGS}"$'\n'"winlp4ever/dim0-webui:latest" | |
| fi | |
| { | |
| echo "backend<<EOF" | |
| echo "$BACKEND_TAGS" | |
| echo "EOF" | |
| echo "webui<<EOF" | |
| echo "$WEBUI_TAGS" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push backend image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./backend/Dockerfile | |
| push: true | |
| tags: ${{ steps.docker_tags.outputs.backend }} | |
| - name: Build and push web UI image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./webui/Dockerfile | |
| push: true | |
| tags: ${{ steps.docker_tags.outputs.webui }} |