From 3bff67e467e448a70061696094749f2996eb2b84 Mon Sep 17 00:00:00 2001 From: Jairus Martinez Date: Wed, 4 Jun 2025 15:08:39 -0700 Subject: [PATCH 1/7] Add post-create command to install xdg-utils --- README.md | 1 + src/dbt-fusion/.devcontainer/devcontainer.json | 2 ++ 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index 5c5b88c..4b8864d 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ For a detailed configuration (and comments about what each is for), check out th ], "workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=cached", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "postCreateCommand": "sudo apt-get update && sudo apt-get install -y xdg-utils", // enables automatic browser opening for authentication "customizations": { "vscode": { "settings": { diff --git a/src/dbt-fusion/.devcontainer/devcontainer.json b/src/dbt-fusion/.devcontainer/devcontainer.json index 318e675..2b37e06 100644 --- a/src/dbt-fusion/.devcontainer/devcontainer.json +++ b/src/dbt-fusion/.devcontainer/devcontainer.json @@ -16,6 +16,8 @@ // Workspace configuration "workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=cached", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Enables automatic browser opening for authentication + "postCreateCommand": "sudo apt-get update && sudo apt-get install -y xdg-utils", // Configure tool-specific properties. "customizations": { // Configure properties specific to VS Code. From 2dc9e50b262e8276cc821e40456b88635cf35074 Mon Sep 17 00:00:00 2001 From: Jairus Martinez Date: Wed, 4 Jun 2025 15:08:59 -0700 Subject: [PATCH 2/7] Remove unnecessary options key --- src/dbt-fusion/devcontainer-template.json | 27 +++-------------------- 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/dbt-fusion/devcontainer-template.json b/src/dbt-fusion/devcontainer-template.json index a62566e..ac31d06 100644 --- a/src/dbt-fusion/devcontainer-template.json +++ b/src/dbt-fusion/devcontainer-template.json @@ -1,28 +1,7 @@ { "name": "dbt Fusion", "version": "1.0.3", - "description": "A development container for dbt projects that use the new fusion engine with the official dbt VS Code extension. ", + "description": "A development container for dbt projects that use the new fusion engine with the official dbt VS Code extension.", "documentationURL": "https://github.com/jairus-m/dbt-fusion-devcontainer", - "licenseURL": "https://github.com/jairus-m/dbt-fusion-devcontainer/blob/main/LICENSE", - "options": { - "imageVariant": { - "type": "string", - "description": "Debian OS version (use bullseye on local arm64/Apple Silicon, bookworm elsewhere)", - "proposals": [ - "bullseye", - "bookworm" - ], - "default": "bullseye" - }, - "pythonVersion": { - "type": "string", - "description": "Python version to use", - "proposals": [ - "3.12", - "3.11", - "3.10" - ], - "default": "3.12" - } - } -} \ No newline at end of file + "licenseURL": "https://github.com/jairus-m/dbt-fusion-devcontainer/blob/main/LICENSE" +} \ No newline at end of file From a6dacad9a0de91d82bb24dbd4e843de6dca54476 Mon Sep 17 00:00:00 2001 From: Jairus Martinez Date: Wed, 4 Jun 2025 15:15:21 -0700 Subject: [PATCH 3/7] Move xdg-utils install to Dockerfile --- README.md | 1 - src/dbt-fusion/.devcontainer/Dockerfile | 3 ++- src/dbt-fusion/.devcontainer/devcontainer.json | 2 -- test/dbt-fusion/test.sh | 3 +++ 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4b8864d..5c5b88c 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,6 @@ For a detailed configuration (and comments about what each is for), check out th ], "workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=cached", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", - "postCreateCommand": "sudo apt-get update && sudo apt-get install -y xdg-utils", // enables automatic browser opening for authentication "customizations": { "vscode": { "settings": { diff --git a/src/dbt-fusion/.devcontainer/Dockerfile b/src/dbt-fusion/.devcontainer/Dockerfile index 2ae6aef..f3182c7 100644 --- a/src/dbt-fusion/.devcontainer/Dockerfile +++ b/src/dbt-fusion/.devcontainer/Dockerfile @@ -1,10 +1,11 @@ # Use the official Python image as the base image FROM python:3.12-slim -# Install system dependencies (i.e. git, curl) +# Install system dependencies (i.e. git, curl, xdg-utils) RUN apt-get update && apt-get install -y \ git \ curl \ + xdg-utils \ && rm -rf /var/lib/apt/lists/* # Install uv using pip diff --git a/src/dbt-fusion/.devcontainer/devcontainer.json b/src/dbt-fusion/.devcontainer/devcontainer.json index 2b37e06..318e675 100644 --- a/src/dbt-fusion/.devcontainer/devcontainer.json +++ b/src/dbt-fusion/.devcontainer/devcontainer.json @@ -16,8 +16,6 @@ // Workspace configuration "workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=cached", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", - // Enables automatic browser opening for authentication - "postCreateCommand": "sudo apt-get update && sudo apt-get install -y xdg-utils", // Configure tool-specific properties. "customizations": { // Configure properties specific to VS Code. diff --git a/test/dbt-fusion/test.sh b/test/dbt-fusion/test.sh index ea8e3e6..9ae32fd 100755 --- a/test/dbt-fusion/test.sh +++ b/test/dbt-fusion/test.sh @@ -13,4 +13,7 @@ docker run --rm dbt-fusion-test uv --version # Test git installation docker run --rm dbt-fusion-test git --version +# Test xdg-utils installation +docker run --rm dbt-fusion-test xdg-open --version + echo "All tests passed!" \ No newline at end of file From fb11fece5753dc62542acafdcce231f701fe4f4f Mon Sep 17 00:00:00 2001 From: Jairus Martinez Date: Thu, 5 Jun 2025 07:10:27 -0700 Subject: [PATCH 4/7] Add a PR trigger that builds and pushes to a staging environment --- .github/workflows/publish-template.yml | 38 +++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-template.yml b/.github/workflows/publish-template.yml index 5bc2b85..2db5849 100644 --- a/.github/workflows/publish-template.yml +++ b/.github/workflows/publish-template.yml @@ -3,6 +3,8 @@ name: Publish Template on: push: branches: [ main ] + pull_request: + branches: [ main ] workflow_dispatch: jobs: @@ -35,4 +37,38 @@ jobs: file: ./src/dbt-fusion/.devcontainer/Dockerfile platforms: linux/amd64,linux/arm64 push: true - tags: ghcr.io/${{ github.repository }}/dbt-fusion:latest \ No newline at end of file + tags: ghcr.io/${{ github.repository }}/dbt-fusion:latest + + publish-staging: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push staging template + uses: docker/build-push-action@v5 + with: + context: . + file: ./src/dbt-fusion/.devcontainer/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ghcr.io/${{ github.repository }}/dbt-fusion:pr-${{ github.event.pull_request.number }} + ghcr.io/${{ github.repository }}/dbt-fusion:staging \ No newline at end of file From 1cffefd2bc972bd874fc391f70dc99a83d872b2d Mon Sep 17 00:00:00 2001 From: Jairus Martinez Date: Thu, 5 Jun 2025 07:15:11 -0700 Subject: [PATCH 5/7] Add conditional for merge trigger --- .github/workflows/publish-template.yml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish-template.yml b/.github/workflows/publish-template.yml index 2db5849..b357615 100644 --- a/.github/workflows/publish-template.yml +++ b/.github/workflows/publish-template.yml @@ -8,7 +8,8 @@ on: workflow_dispatch: jobs: - publish: + publish-staging: + if: github.event_name == 'pull_request' runs-on: ubuntu-latest permissions: contents: read @@ -30,17 +31,19 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push template + - name: Build and push staging template uses: docker/build-push-action@v5 with: context: . file: ./src/dbt-fusion/.devcontainer/Dockerfile platforms: linux/amd64,linux/arm64 push: true - tags: ghcr.io/${{ github.repository }}/dbt-fusion:latest - - publish-staging: - if: github.event_name == 'pull_request' + tags: | + ghcr.io/${{ github.repository }}/dbt-fusion:pr-${{ github.event.pull_request.number }} + ghcr.io/${{ github.repository }}/dbt-fusion:staging + + publish: + if: github.event_name == 'push' runs-on: ubuntu-latest permissions: contents: read @@ -62,13 +65,11 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push staging template + - name: Build and push template uses: docker/build-push-action@v5 with: context: . file: ./src/dbt-fusion/.devcontainer/Dockerfile platforms: linux/amd64,linux/arm64 push: true - tags: | - ghcr.io/${{ github.repository }}/dbt-fusion:pr-${{ github.event.pull_request.number }} - ghcr.io/${{ github.repository }}/dbt-fusion:staging \ No newline at end of file + tags: ghcr.io/${{ github.repository }}/dbt-fusion:latest From c2a658421acffc93658984328a8610283e71059b Mon Sep 17 00:00:00 2001 From: Jairus Martinez Date: Thu, 5 Jun 2025 07:32:43 -0700 Subject: [PATCH 6/7] Add clean-up step to remove PR/staging tags --- .github/workflows/publish-template.yml | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/publish-template.yml b/.github/workflows/publish-template.yml index b357615..c21643e 100644 --- a/.github/workflows/publish-template.yml +++ b/.github/workflows/publish-template.yml @@ -5,6 +5,7 @@ on: branches: [ main ] pull_request: branches: [ main ] + types: [closed] workflow_dispatch: jobs: @@ -73,3 +74,40 @@ jobs: platforms: linux/amd64,linux/arm64 push: true tags: ghcr.io/${{ github.repository }}/dbt-fusion:latest + + cleanup-pr-images: + if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true + needs: publish + runs-on: ubuntu-latest + permissions: + packages: write + + steps: + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Delete PR-specific image + run: | + # Delete PR-specific tag + docker run --rm \ + -e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \ + -e PACKAGE_NAME=dbt-fusion \ + -e PACKAGE_TYPE=container \ + -e PACKAGE_OWNER=${{ github.repository_owner }} \ + -e PACKAGE_VERSION=pr-${{ github.event.pull_request.number }} \ + ghcr.io/actions/github-script@v6 + + # Delete staging tag + docker run --rm \ + -e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \ + -e PACKAGE_NAME=dbt-fusion \ + -e PACKAGE_TYPE=container \ + -e PACKAGE_OWNER=${{ github.repository_owner }} \ + -e PACKAGE_VERSION=staging \ + ghcr.io/actions/github-script@v6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 2944576af42c3d2139126bc103c90a3fe44f9e5c Mon Sep 17 00:00:00 2001 From: Jairus Martinez Date: Thu, 5 Jun 2025 08:06:59 -0700 Subject: [PATCH 7/7] Remove types: [closed] from PR trigger --- .github/workflows/publish-template.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/publish-template.yml b/.github/workflows/publish-template.yml index c21643e..105d1b2 100644 --- a/.github/workflows/publish-template.yml +++ b/.github/workflows/publish-template.yml @@ -5,7 +5,6 @@ on: branches: [ main ] pull_request: branches: [ main ] - types: [closed] workflow_dispatch: jobs: