From 8294358c9daac505c703f5960eafe039da22eb0a Mon Sep 17 00:00:00 2001 From: Kyle Shores Date: Thu, 5 Sep 2024 11:57:14 -0500 Subject: [PATCH] trying to publish codespace image (#233) * trying to publish codespace image * triggering build * correcting repository name * correcting image name * removing post create command * build and publish action for tag or push to main --- .devcontainer/Dockerfile.codespace | 8 +-- .devcontainer/devcontainer.json | 4 +- .github/workflows/deploy_codespaces_image.yml | 53 +++++++++++++++++++ 3 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/deploy_codespaces_image.yml diff --git a/.devcontainer/Dockerfile.codespace b/.devcontainer/Dockerfile.codespace index 7b2529a4..35a18c13 100644 --- a/.devcontainer/Dockerfile.codespace +++ b/.devcontainer/Dockerfile.codespace @@ -13,6 +13,8 @@ RUN dnf -y update \ tree \ && dnf clean all -# COPY . /workspaces/music-box -# WORKDIR /workspaces/music-box -# RUN pip3 install -e '.[dev]' +COPY . /workspaces/music-box + +WORKDIR /workspaces/music-box + +RUN pip3 install -e '.[dev]' \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 88c138a9..ea3550dd 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,10 +1,10 @@ { "name": "MusicBox", - "dockerFile": "Dockerfile.codespace", + "image": "ghcr.io/ncar/music-box:latest", "extensions": [ "ms-python.python", ], "settings": { }, - "postCreateCommand": "cd /workspaces/music-box && pip3 install -e '.[dev]' && code sample_waccm_data/README.md" + "postCreateCommand": "" } \ No newline at end of file diff --git a/.github/workflows/deploy_codespaces_image.yml b/.github/workflows/deploy_codespaces_image.yml new file mode 100644 index 00000000..bf55b2a1 --- /dev/null +++ b/.github/workflows/deploy_codespaces_image.yml @@ -0,0 +1,53 @@ +name: Build and Deploy Docker Image + +on: + push: + branches: + - main + tags: + - 'v*.*.*' + workflow_dispatch: + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: .devcontainer/Dockerfile.codespace + push: false + tags: ghcr.io/ncar/music-box:build-temp + + - name: Build and push Docker image (latest) + if: github.ref == 'refs/heads/main' + uses: docker/build-push-action@v4 + with: + context: . + file: .devcontainer/Dockerfile.codespace + push: true + tags: ghcr.io/ncar/music-box:latest + + - name: Build and push Docker image (tagged) + if: startsWith(github.ref, 'refs/tags/') + uses: docker/build-push-action@v4 + with: + context: . + file: .devcontainer/Dockerfile.codespace + push: true + tags: ghcr.io/ncar/music-box:${{ github.ref_name }}