From 8b21ddab517cee481cdf22a666cf0cc29aaf503d Mon Sep 17 00:00:00 2001 From: Joe George Date: Fri, 19 Dec 2025 11:39:58 -0500 Subject: [PATCH 1/2] Deploy from ci --- .github/workflows/ci.yml | 60 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0365186..dd6de4d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,12 +5,66 @@ on: branches: ["main"] pull_request: branches: ["main"] + schedule: + - cron: "0 0 * * 0" jobs: - build-container: + build-push-deploy: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - - name: Build container - run: docker build -t hello-icerpc . + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: ${{ github.event_name != 'pull_request' }} + platforms: linux/amd64,linux/arm64 + tags: | + icerpc/hello:latest + ghcr.io/icerpc/hello:latest + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Deploy + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.HELLO_HOST }} + username: ${{ secrets.HELLO_USERNAME }} + key: ${{ secrets.SSH_DEPLOY_KEY }} + script_stop: true + script: | + cd /opt/hello + docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} + docker compose pull hello-icerpc + docker compose up -d hello-icerpc + docker system prune -f + + - name: Delete old container images + uses: actions/delete-package-versions@v5 + with: + package-name: hello + package-type: container + min-versions-to-keep: 10 + delete-only-untagged-versions: true From 8c45e72547727b21a74d16085a3ddd01c048f0cb Mon Sep 17 00:00:00 2001 From: Joe George Date: Fri, 19 Dec 2025 11:44:45 -0500 Subject: [PATCH 2/2] Conditional deploy --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd6de4d..14a4316 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,6 +49,7 @@ jobs: - name: Deploy uses: appleboy/ssh-action@v1.0.3 + if: github.event_name != 'pull_request' with: host: ${{ secrets.HELLO_HOST }} username: ${{ secrets.HELLO_USERNAME }}