From b2971ba9c7e9e609c637518ea3718e6c747d1ec5 Mon Sep 17 00:00:00 2001 From: eberrigan Date: Mon, 25 Nov 2024 10:35:44 -0800 Subject: [PATCH] add workflows for vscode tunnel containers --- .../sleap_vscode_tunnel_production.yml | 69 +++++++++++++++++++ .../workflows/sleap_vscode_tunnel_test.yml | 68 ++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 .github/workflows/sleap_vscode_tunnel_production.yml create mode 100644 .github/workflows/sleap_vscode_tunnel_test.yml diff --git a/.github/workflows/sleap_vscode_tunnel_production.yml b/.github/workflows/sleap_vscode_tunnel_production.yml new file mode 100644 index 0000000..714f3bc --- /dev/null +++ b/.github/workflows/sleap_vscode_tunnel_production.yml @@ -0,0 +1,69 @@ +name: Build and Push sleap-vscode-tunnel (Production Workflow) + +# Run on push to main branch after testing is complete +on: + push: + branches: + - main + paths: + - sleap_vscode_tunnel/** # Only run on changes to sleap_vscode_tunnel + - .github/workflows/sleap_vscode_tunnel_production.yml # Only run on changes to this workflow + +jobs: + build: + runs-on: ubuntu-latest # Only build on Ubuntu for now since Docker is not available on macOS runners + strategy: + matrix: + platform: [linux/amd64] # Only build amd64 for now + max-parallel: 2 # Build both architectures in parallel (if more than one) + outputs: + git_sha: ${{ steps.get_sha.outputs.sha }} + sanitized_platform: ${{ steps.sanitize_platform.outputs.sanitized_platform }} + steps: + - name: Checkout code + # https://github.com/actions/checkout + uses: actions/checkout@v4 + + - name: Get Git SHA + id: get_sha + run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + + - name: Debug Git SHA + run: echo "Git SHA ${{ steps.get_sha.outputs.sha }}" + + # Generate a sanitized platform string with slashes replaced by dashes + - name: Sanitize platform name + id: sanitize_platform + run: | + sanitized_platform="${{ matrix.platform }}" # Copy platform value + sanitized_platform="${sanitized_platform/\//-}" # Replace / with - + echo "sanitized_platform=$sanitized_platform" >> $GITHUB_OUTPUT + + - name: Set up Docker Buildx + # https://github.com/docker/setup-buildx-action + uses: docker/setup-buildx-action@v3 + with: + driver: docker-container # Use a container driver for Buildx (default) + + - name: Log in to Docker Hub + # https://github.com/docker/login-action + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + # https://github.com/docker/build-push-action + uses: docker/build-push-action@v6 + with: + context: ./sleap_vscode_tunnel # Build context wrt the root of the repository + file: ./sleap_vscode_tunnel/Dockerfile # Path to Dockerfile wrt the root of the repository + platforms: ${{ matrix.platform }} + push: true # Push the image to Docker Hub + # Tags for the production images, including the "latest" tag + tags: | + ${{ vars.DOCKERHUB_USERNAME }}/sleap-vscode-tunnel:latest + ${{ vars.DOCKERHUB_USERNAME }}/sleap-vscode-tunnel:${{ steps.sanitize_platform.outputs.sanitized_platform }} + ${{ vars.DOCKERHUB_USERNAME }}/sleap-vscode-tunnel:${{ steps.sanitize_platform.outputs.sanitized_platform }}-nvidia-cuda-11.3.1-cudnn8-runtime-ubuntu20.04 + ${{ vars.DOCKERHUB_USERNAME }}/sleap-vscode-tunnel:${{ steps.sanitize_platform.outputs.sanitized_platform }}-sleap-1.3.4 + ${{ vars.DOCKERHUB_USERNAME }}/sleap-vscode-tunnel:${{ steps.sanitize_platform.outputs.sanitized_platform }}-${{ steps.get_sha.outputs.sha }} \ No newline at end of file diff --git a/.github/workflows/sleap_vscode_tunnel_test.yml b/.github/workflows/sleap_vscode_tunnel_test.yml new file mode 100644 index 0000000..2a9ee71 --- /dev/null +++ b/.github/workflows/sleap_vscode_tunnel_test.yml @@ -0,0 +1,68 @@ +name: Build and Push sleap-vscode-tunnel (Test Workflow) + +# Run on push to branches other than main for sleap_vscode_tunnel +on: + push: + branches-ignore: + - main + paths: + - sleap_vscode_tunnel/** # Only run on changes to sleap_vscode_tunnel + - .github/workflows/sleap_vscode_tunnel_test.yml # Only run on changes to this workflow + +jobs: + build: + runs-on: ubuntu-latest # Only build on Ubuntu for now since Docker is not available on macOS runners + strategy: + matrix: + platform: [linux/amd64] # Only build amd64 for now + max-parallel: 2 # Build both architectures in parallel (if more than one) + outputs: + git_sha: ${{ steps.get_sha.outputs.sha }} + sanitized_platform: ${{ steps.sanitize_platform.outputs.sanitized_platform }} + steps: + - name: Checkout code + # https://github.com/actions/checkout + uses: actions/checkout@v4 + + - name: Get Git SHA + id: get_sha + run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + + - name: Debug Git SHA + run: echo "Git SHA ${{ steps.get_sha.outputs.sha }}" + + # Generate a sanitized platform string with slashes replaced by dashes + - name: Sanitize platform name + id: sanitize_platform + run: | + sanitized_platform="${{ matrix.platform }}" # Copy platform value + sanitized_platform="${sanitized_platform/\//-}" # Replace / with - + echo "sanitized_platform=$sanitized_platform" >> $GITHUB_OUTPUT + + - name: Set up Docker Buildx + # https://github.com/docker/setup-buildx-action + uses: docker/setup-buildx-action@v3 + with: + driver: docker-container # Use a container driver for Buildx (default) + + - name: Log in to Docker Hub + # https://github.com/docker/login-action + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + # https://github.com/docker/build-push-action + uses: docker/build-push-action@v6 + with: + context: ./sleap_vscode_tunnel # Build context wrt the root of the repository + file: ./sleap_vscode_tunnel/Dockerfile # Path to Dockerfile wrt the root of the repository + platforms: ${{ matrix.platform }} + push: true # Push the image to Docker Hub + # Tags all include "-test" to differentiate from production images + tags: | + ${{ vars.DOCKERHUB_USERNAME }}/sleap-vscode-tunnel:${{ steps.sanitize_platform.outputs.sanitized_platform }}-test + ${{ vars.DOCKERHUB_USERNAME }}/sleap-vscode-tunnel:${{ steps.sanitize_platform.outputs.sanitized_platform }}-nvidia-cuda-11.3.1-cudnn8-runtime-ubuntu20.04-test + ${{ vars.DOCKERHUB_USERNAME }}/sleap-vscode-tunnel:${{ steps.sanitize_platform.outputs.sanitized_platform }}-sleap-1.3.4-test + ${{ vars.DOCKERHUB_USERNAME }}/sleap-vscode-tunnel:${{ steps.sanitize_platform.outputs.sanitized_platform }}-${{ steps.get_sha.outputs.sha }}-test