From 31f97457aeb176e73a0d75aeff2c132eabd04c38 Mon Sep 17 00:00:00 2001 From: SydZero Date: Mon, 16 Sep 2024 13:42:13 -0500 Subject: [PATCH 1/4] add docer image action --- .github/docker_image.yml | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/docker_image.yml diff --git a/.github/docker_image.yml b/.github/docker_image.yml new file mode 100644 index 0000000..dcd4ac0 --- /dev/null +++ b/.github/docker_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 }} \ No newline at end of file From fe3e9625f605cc7b30049aeef1a05766a1f983cb Mon Sep 17 00:00:00 2001 From: SydZero Date: Mon, 16 Sep 2024 13:42:47 -0500 Subject: [PATCH 2/4] add docker image action --- .github/docker_image.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/docker_image.yml b/.github/docker_image.yml index dcd4ac0..dddec72 100644 --- a/.github/docker_image.yml +++ b/.github/docker_image.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - docker_workflow tags: - 'v*.*.*' workflow_dispatch: From 1f6f955f679f3ec4147bf8196db18d6ef1eb6ed5 Mon Sep 17 00:00:00 2001 From: SydZero Date: Mon, 16 Sep 2024 13:47:40 -0500 Subject: [PATCH 3/4] move to correct folder --- .github/{ => workflows}/docker_image.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{ => workflows}/docker_image.yml (100%) diff --git a/.github/docker_image.yml b/.github/workflows/docker_image.yml similarity index 100% rename from .github/docker_image.yml rename to .github/workflows/docker_image.yml From 12b16b3e1d8b49cd43b710b965f5841f7f1a51b0 Mon Sep 17 00:00:00 2001 From: SydZero Date: Mon, 16 Sep 2024 13:53:12 -0500 Subject: [PATCH 4/4] Try with different docker file --- .github/workflows/docker_image.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker_image.yml b/.github/workflows/docker_image.yml index dddec72..a845ad3 100644 --- a/.github/workflows/docker_image.yml +++ b/.github/workflows/docker_image.yml @@ -31,24 +31,24 @@ jobs: uses: docker/build-push-action@v4 with: context: . - file: .devcontainer/Dockerfile.codespace + file: Dockerfile push: false - tags: ghcr.io/ncar/music-box:build-temp + tags: ghcr.io/ncar/chemistry-cafe-api: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 + file: Dockerfile push: true - tags: ghcr.io/ncar/music-box:latest + tags: ghcr.io/ncar/chemistry-cafe-api: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 + file: Dockerfile push: true - tags: ghcr.io/ncar/music-box:${{ github.ref_name }} \ No newline at end of file + tags: ghcr.io/ncar/chemistry-cafe-api:${{ github.ref_name }} \ No newline at end of file