Introduce Flyway to manage db schema (#15) #1
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
name: Continuous Deployment | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
env: | |
DOCKER_REPO: lwitkowski.azurecr.io | |
jobs: | |
build-ui: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
echo "DOCKER_IMAGE=${DOCKER_REPO}/aerooffers-ui:${GITHUB_SHA::7}" >> $GITHUB_ENV | |
- name: 'Build UI' | |
working-directory: ./frontend | |
run: | | |
docker build . -t ${DOCKER_IMAGE} | |
- name: 'Login to ACR' | |
uses: azure/docker-login@v2 | |
if: github.ref == 'refs/heads/main' | |
with: | |
login-server: ${{ env.DOCKER_REPO }} | |
username: ${{ secrets.ACR_USERNAME }} | |
password: ${{ secrets.ACR_PASSWORD }} | |
- name: 'Push image to ACR' | |
if: github.ref == 'refs/heads/main' | |
run: | | |
docker push ${DOCKER_IMAGE} | |
build-api: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
echo "DOCKER_IMAGE=${DOCKER_REPO}/aerooffers-api:${GITHUB_SHA::7}" >> $GITHUB_ENV | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: 'Run tests' | |
working-directory: ./backend | |
run: | | |
pip3 install --quiet -r requirements.txt -r tests/requirements.txt | |
./run_tests.sh | |
- name: 'Build Backend API' | |
working-directory: ./backend | |
run: | | |
docker build . -t ${DOCKER_IMAGE} | |
- name: 'Login to ACR' | |
uses: azure/docker-login@v2 | |
if: github.ref == 'refs/heads/main' | |
with: | |
login-server: ${{ env.DOCKER_REPO }} | |
username: ${{ secrets.ACR_USERNAME }} | |
password: ${{ secrets.ACR_PASSWORD }} | |
- name: 'Push image to ACR' | |
if: github.ref == 'refs/heads/main' | |
run: | | |
docker push ${DOCKER_IMAGE} | |
# only for main builds, and only if both components get built correctly | |
deploy: | |
runs-on: ubuntu-latest | |
environment: production | |
if: github.ref == 'refs/heads/main' | |
needs: | |
- build-ui | |
- build-api | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
echo "API_DOCKER_IMAGE=${DOCKER_REPO}/aerooffers-api:${GITHUB_SHA::7}" >> $GITHUB_ENV | |
echo "UI_DOCKER_IMAGE=${DOCKER_REPO}/aerooffers-ui:${GITHUB_SHA::7}" >> $GITHUB_ENV | |
- name: 'Azure Login' | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: 'Deploy API' | |
uses: azure/container-apps-deploy-action@v2 | |
with: | |
resourceGroup: rg-aerooffers | |
containerAppEnvironment: cae-aerooffers-prod | |
containerAppName: ca-aerooffers-api | |
imageToDeploy: ${{ env.API_DOCKER_IMAGE }} | |
disableTelemetry: true | |
- name: 'Deploy UI' | |
uses: azure/container-apps-deploy-action@v2 | |
with: | |
resourceGroup: rg-aerooffers | |
containerAppEnvironment: cae-aerooffers-prod | |
containerAppName: ca-aerooffers-ui | |
imageToDeploy: ${{ env.UI_DOCKER_IMAGE }} | |
disableTelemetry: true |