diff --git a/.github/workflows/publish-template.yml b/.github/workflows/publish-template.yml index 5bc2b85..105d1b2 100644 --- a/.github/workflows/publish-template.yml +++ b/.github/workflows/publish-template.yml @@ -3,10 +3,47 @@ name: Publish Template on: push: branches: [ main ] + pull_request: + branches: [ main ] workflow_dispatch: jobs: + 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 + publish: + if: github.event_name == 'push' runs-on: ubuntu-latest permissions: contents: read @@ -35,4 +72,41 @@ 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 + + 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 }} 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-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 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