Files
ota-admin-portal/.github/workflows/deploy.yml
Drew Taylor 34d670c101 CEC-1058 fleet forms (#123)
* working fleets page

* unit tests

* snapshots

* updating messages and snapshots

* updating extraneous snaps
2022-03-11 15:48:30 -08:00

91 lines
2.9 KiB
YAML

on:
push:
branches:
- develop
- main
- "release/**"
- "hotfix/**"
jobs:
deploy:
name: Deploy
runs-on: self-hosted
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
steps:
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
- name: Checkout
uses: actions/checkout@v2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-west-2
- name: Create ECR Repo
run: aws ecr create-repository --region us-west-2 --repository-name ${PROJECT} || true
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: 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
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
build-args: ENVIRONMENT=${{ env.ENVIRONMENT }}
push: true
tags: ${{ steps.login-ecr.outputs.registry }}/${{ env.PROJECT }}:${{ env.TAG}}-${{ env.ENVIRONMENT }}
cache-from: type=registry,ref=${{ steps.login-ecr.outputs.registry }}/${{ env.PROJECT }}:${{ env.TAG}}-${{ env.ENVIRONMENT }}
cache-to: type=inline
- name: Notify deploy
uses: rtCamp/action-slack-notify@v2
env:
MSG_MINIMAL: true
SLACK_MESSAGE: "Deploying to ${{ env.ENVIRONMENT }}... :partydeploy:"
- name: Deploy
id: deploy
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
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 if success
if: ${{ success() }}
uses: rtCamp/action-slack-notify@v2
env:
MSG_MINIMAL: true
SLACK_MESSAGE: "Successfully deployed to ${{ env.ENVIRONMENT }}! :gopher_party:"
- name: Notify if failure
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ job.status }}
SLACK_MESSAGE: "Something failed! :this-is-fine:"