Docker Deploy (latest - latest build) #11
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: Deploy to Docker Hub | |
| run-name: Docker Deploy (${{ inputs.docker_tag }} - ${{ inputs.run_id || 'latest build' }}) | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| docker_tag: | |
| description: "Docker tag to deploy" | |
| 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 | |
| permissions: | |
| actions: read | |
| contents: read | |
| jobs: | |
| deploy: | |
| name: Deploy to Docker Hub | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Get Latest Build Run ID | |
| if: inputs.run_id == '' | |
| id: get-run-id | |
| run: | | |
| RUN_ID=$(gh run list --workflow=build.yml --status=success --limit=1 --json databaseId --jq '.[0].databaseId') | |
| echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT | |
| echo "Using build run ID: $RUN_ID" | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| - name: Download Server Artifact | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: Server | |
| path: ./server-publish | |
| github-token: ${{ github.token }} | |
| run-id: ${{ inputs.run_id || steps.get-run-id.outputs.run_id }} | |
| - name: Download docker-compose file | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: DockerCompose | |
| path: ./docker-compose-download | |
| github-token: ${{ github.token }} | |
| run-id: ${{ inputs.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.exe" | |
| "./server-publish/wwwroot/downloads/win-x64/ControlR.Agent.exe" | |
| "./server-publish/wwwroot/downloads/linux-x64/ControlR.Agent" | |
| "./server-publish/wwwroot/downloads/osx-arm64/ControlR.Agent" | |
| "./server-publish/wwwroot/downloads/osx-x64/ControlR.Agent" | |
| "./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 | |
| RUN mkdir -p /app/AppData | |
| RUN chown app:app -R /app/AppData | |
| 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@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PAT }} | |
| - name: Build and Push Docker Image | |
| uses: docker/build-push-action@v5 | |
| 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 "## Deployment 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 |