From 1c5d71c5cbe79147c4ab0f3d76e6a21e71aa7042 Mon Sep 17 00:00:00 2001 From: "Shiny Brar (he/il)" Date: Wed, 12 Jun 2024 15:19:05 -0400 Subject: [PATCH] feat(github-actions): added deployment action to publish docker containers --- .github/workflows/cd.yml | 55 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 41ea4fa..bbcb7a2 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -15,8 +15,61 @@ jobs: steps: - name: Release Please Action - id: release + id: release-please uses: googleapis/release-please-action@v4.1.1 with: release-type: python manifest-file: .release-please-manifest.json + - + name: Checkout buckets code + if: ${{ steps.release-please.outputs.release_created }} + uses: actions/checkout@v3 + with: + fetch-depth: 1 + - + name: Create release tags + id: metadata + if: ${{ steps.release-please.outputs.release_created }} + run: | + echo "Creating release tags for docker image" + IMAGE="chimefrb/workflow" + TAG=${{ steps.release-please.outputs.tag_name }} + echo "image=${IMAGE}:latest" >> $GITHUB_OUTPUT + echo "tagged_image=${IMAGE}:${TAG}" >> $GITHUB_OUTPUT + - + name: Setup ssh-agent + id: ssh-agent-setup + if: ${{ steps.release-please.outputs.release_created }} + uses: webfactory/ssh-agent@v0.4.1 + with: + ssh-private-key: ${{ secrets.CHIMEFRB_BOT_SSH_PRIVATE_KEY }} + - + name: Setup docker-buildx + id: buildx + if: ${{ steps.release-please.outputs.release_created }} + uses: docker/setup-buildx-action@v1 + with: + install: true + - + name: Perform docker-login + if: ${{ steps.release-please.outputs.release_created }} + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - + name: Build & Push docker image + id: build + if: ${{ steps.release-please.outputs.release_created }} + uses: docker/build-push-action@v2 + with: + context: . + target: production + file: Dockerfile + platforms: linux/amd64,linux/arm64 + tags: | + ${{ steps.metadata.outputs.image }} + ${{ steps.metadata.outputs.tagged_image }} + push: true + cache-from: type=gha + cache-to: type=gha,mode=max