Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt committed Jun 4, 2024
1 parent 91ade93 commit 4b02d89
Showing 1 changed file with 75 additions and 72 deletions.
147 changes: 75 additions & 72 deletions .github/workflows/build-push-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
name: Build Docker Images, Push to Registry, and Deploy to Production

on:
push:
branches:
- main
release:
types: [published]
push
# push:
# branches:
# - main
# release:
# types: [published]

jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
service: [backend, radar, ml]
service: [lunary-ee]
# service: [backend, radar, ml]
steps:
- name: Check out the private Ops repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -53,75 +55,76 @@ jobs:
push: true
tags: |
lunary/${{ matrix.service }}:latest
lunary/${{ matrix.service}}:1.2.19
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,linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max

deploy:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Deploy to Production
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.PRODUCTION_IP_ADDRESS }}
username: root
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.PRODUCTION_PORT }}
script: |
docker image prune -f
cd /opt/lunary
docker compose pull
docker compose down
docker compose up -d
build-and-push-frontend:
needs: deploy
runs-on: ubuntu-latest
steps:
- name: Check out the private Ops repo
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
submodules: "recursive"

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: "lab:latest"
driver: cloud
endpoint: "lunary/lunary"

- name: Generate date
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: 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 frontend
uses: docker/build-push-action@v5
with:
context: .
file: ./ops/frontend.Dockerfile
push: true
tags: |
lunary/frontend:latest
lunary/frontend:rev-${{ steps.date.outputs.date }}-${{ steps.commit.outputs.hash }}
${{ github.event.release.tag_name != '' && format('lunary/frontend:{0}', steps.release_tag.outputs.tag) || '' }}
platforms: linux/arm64,linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
# deploy:
# needs: build-and-push
# runs-on: ubuntu-latest
# steps:
# - name: Deploy to Production
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.PRODUCTION_IP_ADDRESS }}
# username: root
# key: ${{ secrets.SSH_PRIVATE_KEY }}
# port: ${{ secrets.PRODUCTION_PORT }}
# script: |
# docker image prune -f
# cd /opt/lunary
# docker compose pull
# docker compose down
# docker compose up -d

# build-and-push-frontend:
# needs: deploy
# runs-on: ubuntu-latest
# steps:
# - name: Check out the private Ops repo
# uses: actions/checkout@v4
# with:
# token: ${{ secrets.GH_TOKEN }}
# submodules: "recursive"

# - name: Log in to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# with:
# version: "lab:latest"
# driver: cloud
# endpoint: "lunary/lunary"

# - name: Generate date
# 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: 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 frontend
# uses: docker/build-push-action@v5
# with:
# context: .
# file: ./ops/frontend.Dockerfile
# push: true
# tags: |
# lunary/frontend:latest
# lunary/frontend:rev-${{ steps.date.outputs.date }}-${{ steps.commit.outputs.hash }}
# ${{ github.event.release.tag_name != '' && format('lunary/frontend:{0}', steps.release_tag.outputs.tag) || '' }}
# platforms: linux/arm64,linux/amd64
# cache-from: type=gha
# cache-to: type=gha,mode=max

0 comments on commit 4b02d89

Please sign in to comment.