Skip to content

Add integration tests to Internal API. (#618) #224

Add integration tests to Internal API. (#618)

Add integration tests to Internal API. (#618) #224

# This workflow runs automatically on pushes to master that affect Jobs and its dependencies.
# It can also be run manually via workflow_dispatch. It uses check-if-branch-should-deploy
# to prevent cluttering the deployments list with initial release-hotfix- branches.
#
# It follows a build-then-deploy pattern:
# 1. Build: Compiles the Jobs project and upload as artifact
# 2. Deploy to Dev/QA: Download artifact and deploy
# 3. Deploy to Production: Download artifact and deploy
#
# Note: Environment deployments require approval through GitHub environment protection rules
name: Post-merge (Jobs)
on:
push:
branches:
- master
- 'release-hotfix-*'
paths:
- 'Directory.Build.props'
- 'Directory.Packages.props'
- 'src/Aquifer.AI/**'
- 'src/Aquifer.Common/**'
- 'src/Aquifer.Data/**'
- 'src/Aquifer.JSEngine/**'
- 'src/Aquifer.Jobs/**'
- 'src/Aquifer.Tiptap/**'
workflow_dispatch:
permissions:
id-token: write
contents: write
jobs:
check_should_deploy:
runs-on: ubuntu-latest
outputs:
should_deploy: ${{ github.event_name == 'workflow_dispatch' || steps.check_deploy.outputs.should_deploy == 'true' }}
steps:
- id: check_deploy
if: github.event_name != 'workflow_dispatch'
uses: BiblioNexusStudio/github-actions/check-if-branch-should-deploy@master
with:
current_branch: ${{ github.ref_name }}
build:
name: Build
needs:
- check_should_deploy
if: needs.check_should_deploy.outputs.should_deploy == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/[email protected]
- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: '9.x'
- name: Restore .net tools
run: dotnet tool restore
- name: Make build directory
run: mkdir ./build
- name: Build Jobs
run: |
cd src/Aquifer.Jobs
dotnet build --configuration Release --output ../../build --runtime win-x64
cd ../..
- name: Bundle migrations
run: dotnet ef migrations bundle --startup-project src/Aquifer.Migrations --project src/Aquifer.Data --output build/Migrate --self-contained
- name: Publish artifact
uses: actions/[email protected]
with:
include-hidden-files: true
name: build
path: build
deploy_jobs_to_dev_qa:
if: needs.check_should_deploy.outputs.should_deploy == 'true'
name: Deploy Jobs to dev/qa
runs-on: ubuntu-latest
needs:
- build
- check_should_deploy
environment:
name: dev-qa-jobs
steps:
- name: Notify Slack deploy is starting
id: slack-notify
uses: BiblioNexusStudio/github-action-slack-notify-build@main
with:
channel_id: C05UPTGQGP9
status: RUNNING
color: warning
environment: dev-qa-jobs
default_branch_name: master
service_name: Jobs
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
- uses: actions/[email protected]
with:
name: build
path: build
- name: Login to Azure
uses: azure/[email protected]
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Make migration script executable
run: chmod +x ./build/Migrate
shell: bash
- name: Run migrations
run: ./build/Migrate --connection '${{ vars.DB_CONNECTION_URL_DEV_QA }}'
shell: bash
- name: Deploy Jobs to dev/qa
uses: Azure/[email protected]
with:
app-name: ${{ vars.AZURE_FUNCTION_APP_NAME_DEV_QA }}
package: build
publish-profile: ${{ secrets.AZURE_FUNCTION_APP_PUBLISH_PROFILE_DEV_QA }}
- name: Notify Slack deploy status
if: ${{ !cancelled() }}
uses: BiblioNexusStudio/github-action-slack-notify-build@main
with:
channel_id: C05UPTGQGP9
status: ${{ job.status == 'failure' && 'FAILURE' || 'SUCCESS' }}
color: ${{ job.status == 'failure' && 'danger' || 'good' }}
environment: dev-qa-jobs
default_branch_name: master
service_name: Jobs
message_id: ${{ steps.slack-notify.outputs.message_id }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
deploy_jobs_to_prod:
if: needs.check_should_deploy.outputs.should_deploy == 'true'
name: Deploy Jobs to prod
runs-on: ubuntu-latest
needs:
- build
- check_should_deploy
environment:
name: prod-jobs
steps:
- name: Notify Slack deploy is starting
id: slack-notify
uses: BiblioNexusStudio/github-action-slack-notify-build@main
with:
channel_id: C05UPTGQGP9
status: RUNNING
color: warning
environment: prod-jobs
default_branch_name: master
service_name: Jobs
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
- uses: actions/[email protected]
with:
name: build
path: build
- name: Login to Azure
uses: azure/[email protected]
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Make migration script executable
run: chmod +x ./build/Migrate
shell: bash
- name: Run migrations
run: ./build/Migrate --connection '${{ vars.DB_CONNECTION_URL_PROD }}'
shell: bash
- name: Deploy Jobs to prod
uses: Azure/[email protected]
with:
app-name: ${{ vars.AZURE_FUNCTION_APP_NAME_PROD }}
package: build
publish-profile: ${{ secrets.AZURE_FUNCTION_APP_PUBLISH_PROFILE_PROD }}
- name: Notify Slack deploy status
if: ${{ !cancelled() }}
uses: BiblioNexusStudio/github-action-slack-notify-build@main
with:
channel_id: C05UPTGQGP9
status: ${{ job.status == 'failure' && 'FAILURE' || 'SUCCESS' }}
color: ${{ job.status == 'failure' && 'danger' || 'good' }}
environment: prod-jobs
default_branch_name: master
service_name: Jobs
message_id: ${{ steps.slack-notify.outputs.message_id }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}