Skip to content

mail template

mail template #1796

Workflow file for this run

name: Web Client CI
on:
push:
branches:
- main
- dev
concurrency:
group: ${{ github.ref }}-web
cancel-in-progress: true
env:
IMAGE: ${{ github.event.repository.name }}-web-${{ fromJSON('{"main":"prod"}')[github.ref_name] || github.ref_name }}
REGISTRY: ${{ vars.REGISTRY }}
jobs:
build-web:
runs-on: ubuntu-latest
if: ${{ contains(github.event.head_commit.message, '~web') || contains(github.event.head_commit.message, '~deploy') }}
environment: ${{ fromJSON('{"main":"prod"}')[github.ref_name] || github.ref_name }}
env:
NEXT_PUBLIC_API_ENDPOINT: ${{ vars.NEXT_PUBLIC_API_ENDPOINT }}
NEXT_PUBLIC_APPLE_APP_ID: ${{ vars.NEXT_PUBLIC_APPLE_APP_ID }}
NEXT_PUBLIC_BASE_URL: ${{ vars.NEXT_PUBLIC_BASE_URL }}
NEXT_PUBLIC_FACEBOOK_ID: ${{ vars.NEXT_PUBLIC_FACEBOOK_ID }}
NEXT_PUBLIC_GENERATE_SOURCEMAP: ${{ vars.NEXT_PUBLIC_GENERATE_SOURCEMAP }}
NEXT_PUBLIC_GOOGLE_CLIENT_ID: ${{ vars.NEXT_PUBLIC_GOOGLE_CLIENT_ID }}
NEXT_PUBLIC_GOOGLE_MEASUREMENT_ID: ${{ vars.NEXT_PUBLIC_GOOGLE_MEASUREMENT_ID }}
NEXT_PUBLIC_SUPPORT_EMAIL: ${{ vars.NEXT_PUBLIC_SUPPORT_EMAIL }}
steps:
- name: Print Job Description
run: |
echo building \"$IMAGE\" from branch \"${{ github.ref_name }}\"
- name: Git Checkout
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.GIT_SSH_KEY }}
submodules: recursive
- name: Build
run: |
docker build . --file Dockerfile.web --tag $IMAGE:latest \
--build-arg NEXT_PUBLIC_API_ENDPOINT="$NEXT_PUBLIC_API_ENDPOINT" \
--build-arg NEXT_PUBLIC_APPLE_APP_ID="$NEXT_PUBLIC_APPLE_APP_ID" \
--build-arg NEXT_PUBLIC_BASE_URL="$NEXT_PUBLIC_BASE_URL" \
--build-arg NEXT_PUBLIC_FACEBOOK_ID="$NEXT_PUBLIC_FACEBOOK_ID" \
--build-arg NEXT_PUBLIC_GENERATE_SOURCEMAP="$NEXT_PUBLIC_GENERATE_SOURCEMAP" \
--build-arg NEXT_PUBLIC_GOOGLE_CLIENT_ID="$NEXT_PUBLIC_GOOGLE_CLIENT_ID" \
--build-arg NEXT_PUBLIC_GOOGLE_MEASUREMENT_ID="$NEXT_PUBLIC_GOOGLE_MEASUREMENT_ID" \
--build-arg NEXT_PUBLIC_SUPPORT_EMAIL="$NEXT_PUBLIC_SUPPORT_EMAIL"
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to doctl
run: doctl registry login --expiry-seconds 1200
- name: Tag Docker Image
run: docker tag $IMAGE:latest $REGISTRY/$IMAGE:latest
- name: Push Docker Image
run: docker push $REGISTRY/$IMAGE:latest
deploy-web:
needs: build-web
runs-on: ubuntu-latest
environment: ${{ fromJSON('{"main":"prod"}')[github.ref_name] || github.ref_name }}
env:
K8S_NAMESPACE: ${{ secrets.K8S_NAMESPACE }}
K8S_MEMORY_REQUESTS: ${{ vars.K8S_MEMORY_REQUESTS }}
K8S_CPU_REQUESTS: ${{ vars.K8S_CPU_REQUESTS }}
K8S_MEMORY_LIMITS: ${{ vars.K8S_MEMORY_LIMITS }}
K8S_CPU_LIMITS: ${{ vars.K8S_CPU_LIMITS }}
K8S_REPLICA_COUNT_WEB: ${{ vars.K8S_REPLICA_COUNT_WEB }}
PORT: ${{ vars.PORT }}
steps:
- name: Print Job Description
run: |
echo deploying \"$IMAGE\" from branch \"${{ github.ref_name }}\"
- name: Git Checkout
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.GIT_SSH_KEY }}
submodules: recursive
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Add kubectl cert
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 1200 ${{ secrets.K8S_CLUSTER_ID }}
- name: Apply deployment changes
run: envsubst < $GITHUB_WORKSPACE/k8s/web-deploy.yaml | kubectl apply -f -
- name: Deploy Rollout
run: kubectl rollout restart deployment/$IMAGE --namespace $K8S_NAMESPACE
- name: Verify deployment
run: kubectl rollout status deployment/$IMAGE --namespace $K8S_NAMESPACE