Skip to content

remove letsencrypt conf #510

remove letsencrypt conf

remove letsencrypt conf #510

# Note that the deploy steps expect that backend/Cargo.toml and deploys/k8s/load_balancer.yaml
# have the same version number.
name: Load Balancer CI/CD
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_call:
secrets:
DOCKERHUB_USERNAME:
description: 'DockerHub username for CD'
required: true
DOCKERHUB_TOKEN:
description: 'DockerHub access token for CD'
required: true
jobs:
build_rust_binaries:
name: Build Rust Binaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Extract Versioning Data
id: vars
run: |-
echo "be_version=$(cat backend/Cargo.toml | grep 'version =' | sed -n 1p | awk '{print $3;}' | sed 's/"//g')" >> $GITHUB_OUTPUT
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Store Versioning Data for release ${{ steps.vars.outputs.be_version }}-${{ steps.vars.outputs.sha_short }}
run: echo ${{ steps.vars.outputs.sha_short }} > deploys/docker/continuous_delivery_hash
- uses: dtolnay/rust-toolchain@stable
- uses: arduino/setup-protoc@v3
- uses: Swatinem/rust-cache@v2
with:
workspaces: ./backend -> target
# default key
key: jonline-lb-build-${{ runner.OS }}-github-build
shared-key: jonline-lb-build-${{ runner.OS }}-github-build
- working-directory: backend
run: cargo build --release
- uses: actions/cache/save@v4
id: rust-app-cache
with:
path: backend/target/release
key: rust-lb-${{ steps.vars.outputs.be_version }}-${{ steps.vars.outputs.sha_short }}
test_rust_binaries:
name: Test Rust Binaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: arduino/setup-protoc@v3
# - run: sudo apt install libprotobuf-dev protobuf-compiler
- uses: Swatinem/rust-cache@v2
with:
workspaces: ./backend -> target
# default key
key: jonline-lb-test-${{ runner.OS }}-github-test
shared-key: jonline-lb-test-${{ runner.OS }}-github-test
- working-directory: backend
run: cargo test --all-features
- working-directory: backend
run: cargo build --all-features
push_jbl:
name: Push JBL Image
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- build_rust_binaries
steps:
- uses: actions/checkout@v4
- name: Extract Versioning Data
id: vars
run: |-
echo "be_version=$(cat backend/Cargo.toml | grep 'version =' | sed -n 1p | awk '{print $3;}' | sed 's/"//g')" >> $GITHUB_OUTPUT
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Store Versioning Data for release ${{ steps.vars.outputs.be_version }}-${{ steps.vars.outputs.sha_short }}
run: echo ${{ steps.vars.outputs.sha_short }} > deploys/docker/continuous_delivery_hash
- uses: actions/cache/restore@v4
id: rust-app-cache
with:
path: backend/target/release
key: rust-lb-${{ steps.vars.outputs.be_version }}-${{ steps.vars.outputs.sha_short }}
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Rename Rust binaries for Dockerfiles
run: >-
mv backend/target/release/load_balancer backend/target/release/load_balancer__server_release
- name: Build and push jonline image
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/jbl:${{ steps.vars.outputs.be_version }}-${{ steps.vars.outputs.sha_short }}
context: .
file: ./deploys/docker/load_balancer/Dockerfile
platforms: linux/amd64,linux/arm64
deploy_jbl_to_jonline_be:
name: Deploy JBL on Jonline-BE cluster
if: github.ref == 'refs/heads/main'
needs:
- test_rust_binaries
- push_jbl
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Extract Versioning Data
id: vars
run: |-
echo "be_version=$(cat backend/Cargo.toml | grep 'version =' | sed -n 1p | awk '{print $3;}' | sed 's/"//g')" >> $GITHUB_OUTPUT
echo "sha_short=$(git rev-parse --short=7 HEAD)" >> $GITHUB_OUTPUT
- uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Update deploys/k8s/load_balancer.yaml to use ${{ steps.vars.outputs.be_version }}-${{ steps.vars.outputs.sha_short }}
run: sed -i 's|${{ steps.vars.outputs.be_version }}|${{ steps.vars.outputs.be_version }}-${{ steps.vars.outputs.sha_short }}|g' deploys/k8s/load_balancer.yaml
- name: Save DigitalOcean kubeconfig with short-lived credentials
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 jonline-be
# If you haven't already integrated with your registry and only want workloads in a particular namespace to be able to pull
# from your registry, uncomment the next two commands.
# - name: Upload credentials of your registry to your DigitalOcean Kubernetes cluster
# run: doctl registry kubernetes-manifest | kubectl apply -f -
# - name: Reference the secret you just uploaded as an imagePullSecrets
# run: "kubectl patch serviceaccount default -p '{\"imagePullSecrets\": [{\"name\": \"registry-<your-registry-name>`\"}]}'"
- name: Deploy to Jonline-BE via DigitalOcean Kubernetes
run: kubectl apply -f deploys/k8s/load_balancer.yaml -n jonline
- name: Verify LB deployment
run: kubectl rollout status deployment/jonline-lb -n jonline --timeout 2m