Merge pull request #446 from Fisker-Inc/thnguyen-main-v2-on-demand-deploy
Filling out rest of v2 on demand deploy
This commit is contained in:
112
.github/workflows/deploy-on-demand-v2.yml
vendored
112
.github/workflows/deploy-on-demand-v2.yml
vendored
@@ -9,3 +9,115 @@ on:
|
|||||||
type: choice
|
type: choice
|
||||||
options:
|
options:
|
||||||
- dev
|
- dev
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
build-env: ${{ steps.set-env.outputs.ENVIRONMENT }}
|
||||||
|
steps:
|
||||||
|
- name: Slack Notification
|
||||||
|
uses: rtCamp/action-slack-notify@v2
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Azure Login
|
||||||
|
uses: azure/login@v1
|
||||||
|
with:
|
||||||
|
creds: ${{ secrets.AZURE_CREDENTIALS }}
|
||||||
|
|
||||||
|
- name: Login to ACR
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
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 Env
|
||||||
|
env:
|
||||||
|
ENV: ${{ inputs.environment }}
|
||||||
|
id: set-env
|
||||||
|
run: |
|
||||||
|
case ${ENV} in
|
||||||
|
dev)
|
||||||
|
ENVIRONMENT=dev;;
|
||||||
|
stage)
|
||||||
|
ENVIRONMENT=stg;;
|
||||||
|
preprod)
|
||||||
|
ENVIRONMENT=prd;;
|
||||||
|
*)
|
||||||
|
ENVIRONMENT=dev;;
|
||||||
|
esac
|
||||||
|
echo "ENVIRONMENT=${ENVIRONMENT}" >> $GITHUB_ENV
|
||||||
|
echo "ENVIRONMENT=${ENVIRONMENT}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
build-args: ENVIRONMENT=${{ env.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 }} ${{ inputs.environment }}! :this-is-fine:"
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
needs: build
|
||||||
|
runs-on: [self-hosted, azure]
|
||||||
|
env:
|
||||||
|
ENVIRONMENT: ${{ needs.build.outputs.build-env }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- uses: rtCamp/action-slack-notify@v2
|
||||||
|
env:
|
||||||
|
MSG_MINIMAL: true
|
||||||
|
SLACK_MESSAGE: "Deploying ${{ env.PROJECT }} to ${{ inputs.environment }}... :partydeploy:"
|
||||||
|
|
||||||
|
- name: Deploy
|
||||||
|
run: |-
|
||||||
|
helm upgrade \
|
||||||
|
--kube-context $ENVIRONMENT \
|
||||||
|
--set image.registry=$REGISTRY \
|
||||||
|
--set image.name=$PROJECT \
|
||||||
|
--set image.tag=$TAG \
|
||||||
|
--wait -i -f k8s/values-$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:"
|
||||||
|
|||||||
Reference in New Issue
Block a user