* CEC-3236 Germany testing initial workflow * CEC-3236 Germany testing * CEC-3236 testing germany * CEC-3236 removing euprdTest and adding it to deploy Co-authored-by: Christopher Rai <christopherrai@Christophers-MacBook-Pro.local>
167 lines
5.2 KiB
YAML
167 lines
5.2 KiB
YAML
name: OTA Portal Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- develop
|
|
- main
|
|
- "release/**"
|
|
- "hotfix/**"
|
|
|
|
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"
|
|
TAG: ${{ github.sha }}
|
|
PROJECT: ota-admin-portal
|
|
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: Set Env
|
|
id: set-env
|
|
run: |
|
|
case ${GITHUB_REF} in
|
|
refs/heads/develop)
|
|
ENVIRONMENT=dev;;
|
|
refs/heads/release/*)
|
|
ENVIRONMENT=stg;;
|
|
refs/heads/hotfix/*)
|
|
ENVIRONMENT=stg;;
|
|
refs/heads/main)
|
|
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@v3
|
|
with:
|
|
context: .
|
|
build-args: ENVIRONMENT=${{ env.ENVIRONMENT }}
|
|
push: true
|
|
tags: ${{ env.REGISTRY }}/${{ env.PROJECT }}:${{ env.TAG }}-${{ env.ENVIRONMENT }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Build and push new prod
|
|
if: github.ref == 'refs/heads/main'
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
context: .
|
|
build-args: ENVIRONMENT=cec-${{ env.ENVIRONMENT }}
|
|
push: true
|
|
tags: ${{ env.REGISTRY }}/${{ env.PROJECT }}:${{ env.TAG }}-cec-${{ env.ENVIRONMENT }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Build and push Germany
|
|
if: github.ref == 'refs/heads/main'
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
context: .
|
|
build-args: ENVIRONMENT=cec-eu${{ env.ENVIRONMENT }}
|
|
push: true
|
|
tags: ${{ env.REGISTRY }}/${{ env.PROJECT }}:${{ env.TAG }}-cec-eu${{ env.ENVIRONMENT }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
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 ${{ env.ENVIRONMENT }}... :partydeploy:"
|
|
|
|
- name: Deploy
|
|
run: |-
|
|
helm upgrade \
|
|
--kube-context $ENVIRONMENT \
|
|
--set image.registry=$REGISTRY \
|
|
--set image.name=$PROJECT \
|
|
--set image.tag=$TAG-$ENVIRONMENT \
|
|
--wait -i -f k8s/values-$ENVIRONMENT.yaml $PROJECT k8s/
|
|
|
|
- name: Notify deploy
|
|
uses: rtCamp/action-slack-notify@v2
|
|
env:
|
|
MSG_MINIMAL: true
|
|
SLACK_MESSAGE: "Successfully deployed ${{ env.PROJECT }} to ${{ env.ENVIRONMENT }}! :gopher_party:"
|
|
|
|
- name: Deploy new prod
|
|
if: github.ref == 'refs/heads/main'
|
|
run: |-
|
|
helm upgrade \
|
|
--kube-context cec-$ENVIRONMENT-cluster-1 \
|
|
--set image.registry=$REGISTRY \
|
|
--set image.name=$PROJECT \
|
|
--set image.tag=$TAG-cec-$ENVIRONMENT \
|
|
--wait -i -f k8s/values-cec-$ENVIRONMENT.yaml $PROJECT k8s/
|
|
|
|
- name: Notify deploy new
|
|
if: github.ref == 'refs/heads/main'
|
|
uses: rtCamp/action-slack-notify@v2
|
|
env:
|
|
MSG_MINIMAL: true
|
|
SLACK_MESSAGE: "Successfully deployed ${{ env.PROJECT }} to cec-${{ env.ENVIRONMENT }}! :gopher_party:"
|
|
|
|
- name: Deploy Germany
|
|
if: github.ref == 'refs/heads/main'
|
|
run: |-
|
|
helm upgrade \
|
|
--kube-context cec-eu$ENVIRONMENT-cluster-1 \
|
|
--set image.registry=$REGISTRY \
|
|
--set image.name=$PROJECT \
|
|
--set image.tag=$TAG-cec-eu$ENVIRONMENT \
|
|
--wait -i -f k8s/values-cec-eu$ENVIRONMENT.yaml $PROJECT k8s/
|
|
|
|
- name: Notify deploy Germany
|
|
if: github.ref == 'refs/heads/main'
|
|
uses: rtCamp/action-slack-notify@v2
|
|
env:
|
|
MSG_MINIMAL: true
|
|
SLACK_MESSAGE: "Successfully deployed ${{ env.PROJECT }} to cec-eu${{ env.ENVIRONMENT }}! :gopher_party:"
|
|
|
|
- name: Notify if failure
|
|
if: ${{ failure() }}
|
|
uses: rtCamp/action-slack-notify@v2
|
|
env:
|
|
SLACK_COLOR: ${{ job.status }}
|
|
SLACK_MESSAGE: "Failed to deploy ${{ env.PROJECT }} to ${{ env.ENVIRONMENT }}! :this-is-fine:"
|