From a63c108efbf84b4c234efcd354d5714c3b1ea4b0 Mon Sep 17 00:00:00 2001 From: Hugues Chocart Date: Wed, 24 Apr 2024 18:02:08 -0300 Subject: [PATCH] ci: improv deployment speed (#250) --- .github/workflows/build-push-deploy.yml | 54 +++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-push-deploy.yml b/.github/workflows/build-push-deploy.yml index e886ab27..51ed3992 100644 --- a/.github/workflows/build-push-deploy.yml +++ b/.github/workflows/build-push-deploy.yml @@ -8,7 +8,7 @@ on: types: [published] jobs: - build-and-push: + build-and-push-amd64: runs-on: ubuntu-latest strategy: matrix: @@ -41,7 +41,7 @@ jobs: id: release_tag run: echo "tag=$(echo ${{ github.event.release.tag_name }} | sed 's/^v//')" >> $GITHUB_OUTPUT - - name: Build and push ${{ matrix.service }} + - name: Build and push ${{ matrix.service }} (amd64) uses: docker/build-push-action@v5 with: context: . @@ -51,10 +51,10 @@ jobs: lunary/${{ matrix.service }}:latest lunary/${{ matrix.service }}:rev-${{ steps.date.outputs.date }}-${{ steps.commit.outputs.hash }} ${{ github.event.release.tag_name != '' && format('lunary/{0}:{1}', matrix.service, steps.release_tag.outputs.tag) || '' }} - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 deploy: - needs: build-and-push + needs: build-and-push-amd64 runs-on: ubuntu-latest steps: - name: Deploy to Production @@ -71,6 +71,52 @@ jobs: docker compose down docker compose up -d + build-and-push-arm64: + needs: deploy + runs-on: ubuntu-latest + strategy: + matrix: + service: [backend, frontend, radar] + steps: + - name: Check out the private Ops repo + uses: actions/checkout@v4 + with: + token: ${{ secrets.GH_ACCESS_TOKEN }} + submodules: "recursive" + + - name: Generate data + id: date + run: echo "date=$(date +%Y-%m-%d-%Hh%Mm%Ss)" >> $GITHUB_OUTPUT + + - name: Get short commit hash + id: commit + run: echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to private Docker Registry + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_REGISTRY_USERNAME }} + password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} + + - name: Remove 'v' prefix from release tag + id: release_tag + run: echo "tag=$(echo ${{ github.event.release.tag_name }} | sed 's/^v//')" >> $GITHUB_OUTPUT + + - name: Build and push ${{ matrix.service }} (arm64) + uses: docker/build-push-action@v5 + with: + context: . + file: ./ops/${{ matrix.service }}.Dockerfile + push: true + tags: | + lunary/${{ matrix.service }}:latest + lunary/${{ matrix.service }}:rev-${{ steps.date.outputs.date }}-${{ steps.commit.outputs.hash }} + ${{ github.event.release.tag_name != '' && format('lunary/{0}:{1}', matrix.service, steps.release_tag.outputs.tag) || '' }} + platforms: linux/arm64 + build-lunary-ee: runs-on: ubuntu-latest steps: