Skip to content

(fix) add default values for offer is_geo and item_rank #25

(fix) add default values for offer is_geo and item_rank

(fix) add default values for offer is_geo and item_rank #25

name: Deploy API Reco
on:
push:
branches:
- main
- staging
- production
paths:
- 'apps/recommendation/api/src/**'
workflow_dispatch:
jobs:
setup-job:
runs-on: [self-hosted, linux, x64]
outputs:
env_name: ${{ steps.set-variable.outputs.env_name }}
steps:
- uses: actions/checkout@v4
- name: Set environment variable
id: set-variable
run: |
if [ ${{ github.ref }} = 'refs/heads/main' ]; then
echo "env_name=dev" >> $GITHUB_OUTPUT
elif [ ${{ github.ref }} = 'refs/heads/staging' ]; then
echo "env_name=staging" >> $GITHUB_OUTPUT
elif [ ${{ github.ref }} = 'refs/heads/production' ]; then
echo "env_name=production" >> $GITHUB_OUTPUT
else
echo "env_name=dev" >> $GITHUB_OUTPUT
fi
api-reco-coverage-tests:
needs: setup-job
uses: ./.github/workflows/reusable_api_reco_coverage_tests.yml
deploy-api-reco:
needs:
- api-reco-coverage-tests
- setup-job
uses: ./.github/workflows/reusable_build_and_deploy_api.yml
with:
API_NAME: recommendation
API_SOURCE_PATH: "apps/recommendation/api"
TARGET_ENV: ${{ needs.setup-job.outputs.env_name }}
API_SERVICE_NAME: "api-recommendation"
secrets:
GCP_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
ARTIFACT_REGISTRY_SERVICE_ACCOUNT: ${{ secrets.ARTIFACT_REGISTRY_SERVICE_ACCOUNT }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
api-reco-test-integration:
uses: ./.github/workflows/reusable_api_reco_integration_tests.yml
needs:
- setup-job
- deploy-api-reco
with:
TARGET_ENV: ${{ needs.setup-job.outputs.env_name }}
secrets:
GCP_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
ARTIFACT_REGISTRY_SERVICE_ACCOUNT: ${{ secrets.ARTIFACT_REGISTRY_SERVICE_ACCOUNT }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
slack-notification:
runs-on: [self-hosted, linux, x64]
environment: ${{ needs.setup-job.outputs.env_name }}
needs:
- setup-job
- api-reco-test-integration
if: ${{ always() }}
steps:
- uses: technote-space/workflow-conclusion-action@v3
- name: Post to a Slack channel
id: slack
if: ${{ always() }}
uses: slackapi/[email protected]
with:
channel-id: "C01GVAXM02W" # alerts_data
payload: |
{
"attachments": [
{
"mrkdwn_in": ["text"],
"color": "${{ fromJSON('["#36a64f", "#A30002"]')[ env.WORKFLOW_CONCLUSION == 'failure'] }}",
"author_name": "${{github.actor}}",
"author_link": "https://github.com/${{github.actor}}",
"author_icon": "https://github.com/${{github.actor}}.png",
"title": "API Reco Deployment",
"title_link": "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}",
"text": "Le déploiement de `l'API reco sur ${{ needs.setup-job.outputs.env_name }}` est ${{ fromJSON('["réussi", "échoué"]')[env.WORKFLOW_CONCLUSION == 'failure'] }} ${{ fromJSON('[":muscle:", ":boom:"]')[env.WORKFLOW_CONCLUSION == 'failure'] }}"
}
],
"unfurl_links": false,
"unfurl_media": false
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}