Skip to content

Commit

Permalink
ci: improv deployment speed (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt authored Apr 24, 2024
1 parent a5e527d commit a63c108
Showing 1 changed file with 50 additions and 4 deletions.
54 changes: 50 additions & 4 deletions .github/workflows/build-push-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
types: [published]

jobs:
build-and-push:
build-and-push-amd64:
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -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: .
Expand All @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit a63c108

Please sign in to comment.