Repository navigation
Docker Publish (preview - latest build) #7
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: Publish to Docker Hub | |
| run-name: Docker Publish (${{ inputs.docker_tag }} - ${{ inputs.run_id || 'latest build' }}) | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| docker_tag: | |
| description: "Docker tag to publish" | |
| required: true | |
| type: choice | |
| options: | |
| - dev | |
| - preview | |
| - latest | |
| default: "dev" | |
| run_id: | |
| description: "Build workflow run ID (leave empty to use latest)" | |
| required: false | |
| type: string | |
| workflow_call: | |
| inputs: | |
| docker_tag: | |
| description: "Docker tag to publish" | |
| required: true | |
| type: string | |
| run_id: | |
| description: "Build workflow run ID (leave empty to use latest)" | |
| required: false | |
| type: string | |
| permissions: | |
| actions: read | |
| contents: read | |
| jobs: | |
| publish: | |
| name: Publish to Docker Hub | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Get Latest Build Run ID | |
| id: get-run-id | |
| uses: ./.github/actions/get-latest-build-run-id | |
| with: | |
| run_id: ${{ inputs.run_id }} | |
| github_token: ${{ github.token }} | |
| - name: Download Server Artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: Server | |
| path: ./server-publish | |
| github-token: ${{ github.token }} | |
| run-id: ${{ steps.get-run-id.outputs.run_id }} | |
| - name: Download docker-compose file | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: DockerCompose | |
| path: ./docker-compose-download | |
| github-token: ${{ github.token }} | |
| run-id: ${{ steps.get-run-id.outputs.run_id }} | |
| - name: Get Version from Version.txt | |
| id: get-version | |
| shell: bash | |
| run: | | |
| VERSION=$(cat ./server-publish/wwwroot/downloads/Version.txt) | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION" | |
| - name: Verify Downloaded Files | |
| shell: bash | |
| run: | | |
| TEST_PATHS=( | |
| "./server-publish/wwwroot/downloads/Version.txt" | |
| "./server-publish/wwwroot/downloads/win-x86/ControlR.Agent.Installer.exe" | |
| "./server-publish/wwwroot/downloads/win-x64/ControlR.Agent.Installer.exe" | |
| "./server-publish/wwwroot/downloads/win-x86/ControlR.Agent.bundle.zip" | |
| "./server-publish/wwwroot/downloads/win-x64/ControlR.Agent.bundle.zip" | |
| "./server-publish/wwwroot/downloads/linux-x64/ControlR.Agent.Installer" | |
| "./server-publish/wwwroot/downloads/linux-x64/ControlR.Agent.bundle.zip" | |
| "./server-publish/wwwroot/downloads/osx-arm64/ControlR.Agent.Installer" | |
| "./server-publish/wwwroot/downloads/osx-arm64/ControlR.Agent.bundle.zip" | |
| "./server-publish/wwwroot/downloads/osx-x64/ControlR.Agent.Installer" | |
| "./server-publish/wwwroot/downloads/osx-x64/ControlR.Agent.bundle.zip" | |
| "./server-publish/novnc/vnc.html" | |
| ) | |
| for TEST_PATH in "${TEST_PATHS[@]}"; do | |
| if [ ! -f "$TEST_PATH" ] && [ ! -d "$TEST_PATH" ]; then | |
| echo "Error: $TEST_PATH not found." | |
| exit 1 | |
| fi | |
| done | |
| echo "All required files verified successfully" | |
| - name: Create Custom Dockerfile | |
| shell: bash | |
| run: | | |
| cat > ./server-publish/Dockerfile << 'EOF' | |
| FROM mcr.microsoft.com/dotnet/aspnet:10.0 | |
| RUN apt update | |
| RUN apt -y install curl | |
| USER $APP_UID | |
| WORKDIR /app | |
| EXPOSE 8080 | |
| EXPOSE 8081 | |
| COPY . /app | |
| ENTRYPOINT ["dotnet", "ControlR.Web.Server.dll"] | |
| HEALTHCHECK \ | |
| CMD curl -f http://localhost:8080/health || exit 1 | |
| EOF | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PAT }} | |
| - name: Build and Push Docker Image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: ./server-publish | |
| file: ./server-publish/Dockerfile | |
| push: true | |
| tags: | | |
| bitbound/controlr:${{ inputs.docker_tag }} | |
| bitbound/controlr:${{ steps.get-version.outputs.VERSION }} | |
| build-args: | | |
| CURRENT_VERSION=${{ steps.get-version.outputs.VERSION }} | |
| - name: Image Published | |
| run: | | |
| echo "## Publish Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "**Version:** ${{ steps.get-version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY | |
| echo "**Tags:**" >> $GITHUB_STEP_SUMMARY | |
| echo "- bitbound/controlr:${{ inputs.docker_tag }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- bitbound/controlr:${{ steps.get-version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY |