Fix/install slack client (#289) #75
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Backend Deployment | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'backend/**' | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r backend/requirements.txt | |
pip install pytest pylint black | |
- name: Run tests | |
working-directory: ./backend | |
run: pytest | |
- name: Run linting | |
working-directory: ./backend | |
run: | | |
pylint app | |
black --check app | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: ZIP Backend for Deployment | |
run: | | |
cd backend | |
zip -r ../backend.zip . -x "*__pycache__*" "*.git*" "*.pytest_cache*" | |
- name: Deploy to Elastic Beanstalk | |
uses: einaregilsson/beanstalk-deploy@v21 | |
with: | |
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
application_name: ${{ secrets.EB_APPLICATION_NAME }} | |
environment_name: ${{ secrets.EB_ENVIRONMENT_NAME }} | |
region: ${{ secrets.AWS_REGION }} | |
version_label: "backend-${{ github.sha }}" | |
deployment_package: backend.zip | |
- name: Send Slack notification | |
if: always() | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SLACK_CHANNEL: deployments | |
SLACK_COLOR: ${{ job.status }} | |
SLACK_TITLE: Backend Deployment | |
SLACK_MESSAGE: 'Backend deployment ${{ job.status }}' | |
SLACK_FOOTER: 'Toban Contribution Viewer' | |
continue-on-error: true |