128 lines
3.6 KiB
YAML
128 lines
3.6 KiB
YAML
name: OTA Admin Portal v2 Deploy - On Demand
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
environment:
|
|
description: "Environment"
|
|
required: true
|
|
type: choice
|
|
options:
|
|
- dev
|
|
- preprod
|
|
|
|
env:
|
|
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
SLACK_CHANNEL: "#cloud-builds"
|
|
SLACK_FOOTER: ""
|
|
SLACK_USERNAME: GitHub Actions
|
|
SLACK_ICON: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
|
|
JFROG_NPMRC: ${{ secrets.JFROG_NPMRC }}
|
|
TAG: ${{ github.sha }}
|
|
PROJECT: ota-admin-portal-v2
|
|
REGISTRY: fiskercloud.azurecr.io
|
|
|
|
permissions:
|
|
id-token: write
|
|
contents: read
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Slack Notification
|
|
uses: rtCamp/action-slack-notify@v2
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Azure Login
|
|
uses: azure/login@v2
|
|
with:
|
|
creds: ${{ secrets.AZURE_CREDENTIALS }}
|
|
|
|
- name: Login to ACR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ secrets.AZURE_CLIENT_ID }}
|
|
password: ${{ secrets.AZURE_CLIENT_SECRET }}
|
|
|
|
- name: JFrog Auth
|
|
run: echo ${JFROG_NPMRC} | base64 -d > .npmrc
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
build-args: ENVIRONMENT=${{ inputs.environment }}
|
|
push: true
|
|
tags: ${{ env.REGISTRY }}/${{ env.PROJECT }}:${{ env.TAG }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Notify if failure
|
|
if: ${{ failure() }}
|
|
uses: rtCamp/action-slack-notify@v2
|
|
env:
|
|
SLACK_COLOR: ${{ job.status }}
|
|
SLACK_MESSAGE: "Failed to build ${{ env.PROJECT }} in ${{ inputs.environment }}! :this-is-fine:"
|
|
|
|
deploy:
|
|
needs: build
|
|
runs-on: arc-azure-${{ inputs.environment }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Notify deploy
|
|
uses: rtCamp/action-slack-notify@v2
|
|
env:
|
|
MSG_MINIMAL: true
|
|
SLACK_MESSAGE: "Deploying ${{ env.PROJECT }} to ${{ inputs.environment }}... :partydeploy:"
|
|
|
|
- name: Set env
|
|
run: |
|
|
case ${{ inputs.environment }} in
|
|
dev)
|
|
KUBECONFIG=${{ secrets.KUBECONFIG_AZURE_DEV }};;
|
|
preprod)
|
|
KUBECONFIG=${{ secrets.KUBECONFIG_AZURE_PREPROD }};;
|
|
*)
|
|
KUBECONFIG=${{ secrets.KUBECONFIG_AZURE_DEV }};;
|
|
esac
|
|
|
|
echo "KUBECONFIG=${KUBECONFIG}" >> $GITHUB_ENV
|
|
|
|
- name: Deploy to env
|
|
id: deploy
|
|
uses: koslib/helm-eks-action@v1.28.0
|
|
env:
|
|
KUBE_CONFIG_DATA: ${{ env.KUBECONFIG }}
|
|
with:
|
|
command: |
|
|
helm upgrade \
|
|
--atomic \
|
|
--create-namespace \
|
|
--namespace default \
|
|
--set image.registry=$REGISTRY \
|
|
--set image.name=$PROJECT \
|
|
--set image.tag=$TAG \
|
|
--wait -i -f k8s/values-${{ inputs.environment }}.yaml $PROJECT k8s/
|
|
|
|
- name: Notify deploy failure
|
|
if: ${{ failure() }}
|
|
uses: rtCamp/action-slack-notify@v2
|
|
env:
|
|
SLACK_COLOR: ${{ job.status }}
|
|
SLACK_MESSAGE: "Failed to deploy ${{ env.PROJECT }} on ${{ inputs.environment }}! :this-is-fine:"
|
|
|
|
- name: Notify deploy success
|
|
uses: rtCamp/action-slack-notify@v2
|
|
env:
|
|
MSG_MINIMAL: true
|
|
SLACK_MESSAGE: "Successfully deployed ${{ env.PROJECT }} to ${{ inputs.environment }}! :gopher_party:"
|