Skip to content

Docker Deploy (latest - latest build) #5

Docker Deploy (latest - latest build)

Docker Deploy (latest - latest build) #5

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
workflow_call:
inputs:
docker_tag:
description: "Docker tag to deploy"
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:
deploy:
name: Deploy 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.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@v4
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PAT }}
- name: Delete existing dev image
if: inputs.docker_tag == 'dev'
run: |
# Delete the existing image manifest from Docker Hub
# This removes the "dev" tag so we can push the new one fresh
curl -s -X DELETE \
"https://hub.docker.com/v2/repositories/bitbound/controlr/tags/dev/" \
-u "${{ secrets.DOCKER_USERNAME }}:${{ secrets.DOCKER_PAT }}"
echo "Deleted existing dev tag (if it existed)"
- 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 "## 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