Merge pull request #84 from kabirivan/dev-xavier-allient #98
This file contains 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
# Read more about setting it up | |
# https://medium.com/@ljmocic/deploying-react-application-to-aws-s3-using-github-actions-85addacaeace | |
name: fastapi-sqlmodel-alembic | |
on: | |
# Trigger the workflow on push or pull request, | |
# but only for the master branch | |
push: | |
branches: [ main ] | |
tags: | |
- 'v*' | |
#pull_request: | |
# branches: [ main ] | |
jobs: | |
push_to_registry: | |
name: Push Docker image to Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: jrtec/fastapi-alembic-sqlmodel-async | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./backend | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build: | |
name: Build phase | |
runs-on: ubuntu-latest | |
needs: push_to_registry | |
steps: | |
- name: Clone repository | |
id: clone-repository | |
uses: actions/checkout@main | |
- name: Generate deployment package | |
id: generate-deployment-package | |
run: zip -r deploy.zip . -x '*.git*' | |
- name: Deploy to EB | |
id: deploy2b | |
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.AWS_APPLICATION_NAME }} | |
environment_name: ${{ secrets.AWS_ENVIRONMENT_NAME }} | |
version_label: v0.1.${{ github.run_number }} | |
# use_existing_version_if_available: True | |
region: ${{ secrets.AWS_REGION }} | |
deployment_package: deploy.zip | |