Skip to content

deploy

deploy #2582

Workflow file for this run

name: deploy
on:
workflow_dispatch:
inputs:
# Branch is chosen by default in github manual actions
environment:
description: playground, staging or prod for worker and web or exact Env name like iaso-stg-worker
required: true
slack_channel:
description: Slack Channel for notification (iasops by default)
required: false
default: iasops
push:
# On push to main deploy to staging
branches:
- main
jobs:
build:
runs-on: ubuntu-20.04
steps:
# Merge the workflow_dispatch config with some default for deployment via the on:push
- name: Set configs
id: config
env:
DEFAULT_GIT_REFERENCE: main
DEFAULT_ENVIRONMENT: staging
DEFAULT_SLACK_CHANNEL: iasops
run: |
echo "::set-output name=GIT_REFERENCE::${{ github.ref_name || env.DEFAULT_GIT_REFERENCE }}"
echo "::set-output name=ENVIRONMENT::${{ github.event.inputs.environment || env.DEFAULT_ENVIRONMENT }}"
echo "::set-output name=SLACK_CHANNEL::${{ github.event.inputs.slack_channel || env.DEFAULT_SLACK_CHANNEL }}"
- uses: actions/checkout@v2
with:
ref: ${{ steps.config.outputs.GIT_REFERENCE }}
fetch-depth: 0
- name: Deployment of ${{ github.ref_name }} on ${{ steps.config.outputs.ENVIRONMENT }}
id: version
run: |
export GITHUB_BRANCH=${GITHUB_REF##*heads/}
echo $GITHUB_BRANCH
git describe --tags
echo "::set-output name=VERSION_NAME::$(git describe --tags --match "v[[:digit:]]*")"
- name: Slack deployement start
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: ${{ steps.config.outputs.SLACK_CHANNEL }}
SLACK_COLOR: ""
SLACK_USERNAME: ${{ steps.config.outputs.ENVIRONMENT }}
SLACK_ICON_EMOJI: ":robot_face:"
SLACK_TITLE: Started deployement of ${{ steps.version.outputs.VERSION_NAME }} on ${{ steps.config.outputs.ENVIRONMENT }} ...
SLACK_FOOTER: ${{ format('<https://github.com/{0}/commit/{1}/checks|πŸ”—{2} logs> | <https://github.com/{0}/commit/{1}/checks|πŸ”— Commit {1}>', github.repository, github.sha, github.job) }}
MSG_MINIMAL: true
- name: Use node.js 20
uses: actions/setup-node@v2
with:
node-version: '20.13.1'
- name: upgrade npm
run: |
npm install --global [email protected]
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Setup beanstalk
# the specification of botocore is due to a deployment problem with 1.21 to remove later
run: |
cp .elasticbeanstalk/config.github.yml .elasticbeanstalk/config.yml
pip install awsebcli==3.20.5 botocore==1.29.81 boto3==1.26.81
- name: Environment info
run: |
node --version
npm --version
pip list
- name: npm ci
run: |
npm ci
- name: npm build
run: |
rm -f hat/assets/webpack/*
npm run webpack-prod
git add -f hat/assets/webpack/
# add version in python
scripts/set_version.sh
git add -f hat/__version__.py
env:
VERSION_NAME: ${{ steps.version.outputs.VERSION_NAME }}
CI: false
- name: deploy to beanstalk
run: python scripts/eb_deploy.py ${{ steps.config.outputs.ENVIRONMENT }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: "eu-central-1"
VERSION_NAME: ${{ steps.version.outputs.VERSION_NAME }}
- name: Slack deployement success notification
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: ${{ steps.config.outputs.SLACK_CHANNEL }}
SLACK_COLOR: ${{ job.status }}
SLACK_USERNAME: ${{ steps.config.outputs.ENVIRONMENT }}
SLACK_ICON_EMOJI: ":robot_face:"
SLACK_TITLE: Iaso ${{ steps.version.outputs.VERSION_NAME }} successfully deployed on ${{ steps.config.outputs.ENVIRONMENT }}
SLACK_MESSAGE: ${{ format('<https://github.com/{0}/commit/{1}/checks|πŸ”—{2} logs> | <https://github.com/{0}/commit/{1}/checks|πŸ”— Commit {1}>', github.repository, github.sha, github.job) }}
SLACK_FOOTER: "-"
MSG_MINIMAL: true
if: success()
- name: Slack deployement failure notification
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: ${{ steps.config.outputs.SLACK_CHANNEL }}
SLACK_USERNAME: ${{ steps.config.outputs.ENVIRONMENT }}
SLACK_COLOR: ${{ job.status }}
SLACK_ICON_EMOJI: ":robot_face:"
SLACK_TITLE: Deployment failure Iaso ${{ steps.version.outputs.VERSION_NAME }} - ${{ steps.config.outputs.ENVIRONMENT }}
SLACK_MESSAGE: ${{ format('<https://github.com/{0}/commit/{1}/checks|πŸ”—{2} logs> | <https://github.com/{0}/commit/{1}/checks|πŸ”— Commit {1}>', github.repository, github.sha, github.job) }}
SLACK_FOOTER: "-"
MSG_MINIMAL: true
if: failure()