Skip to content

Promote to Production #113

Promote to Production

Promote to Production #113

name: Promote to Production
permissions:
contents: read
pull-requests: read
packages: write
# Only one workflow in a concurrency group may run at a time
concurrency:
group: production-concurrency
cancel-in-progress: true
on:
workflow_dispatch:
jobs:
trigger-github-deployment:
name: Trigger GitHub Deployment
environment: Production
runs-on: ubuntu-latest
steps:
- name: Empty Step
run: echo "Hello World"
get_staging_version:
name: Get version from staging
needs: trigger-github-deployment
outputs:
versionTag: ${{ steps.get_version_tag.outputs.tag }}
runs-on: ubuntu-latest
steps:
- name: Checkout infrastructure
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6
with:
ref: main
repository: equinor/robotics-infrastructure
ssh-key: ${{ secrets.ROBOTICS_INFRASTRUCTURE_DEPLOY_KEY }}
- name: Get Flotilla version in staging
id: get_version_tag
run: |
TAG_LINE_NUMBER=$(($(grep -n "roboticsstagingacr.azurecr.io/robotics/flotilla-frontend" k8s_kustomize/overlays/staging/kustomization.yaml | cut --delimiter=":" --fields=1)+1))
VERSION_TAG=$(sed -n "${TAG_LINE_NUMBER}p" k8s_kustomize/overlays/staging/kustomization.yaml | cut --delimiter=":" --fields=2 | tr -d '[:space:]')
echo "tag=$VERSION_TAG" >> "$GITHUB_OUTPUT"
run_migrations:
name: Update database in Production
needs: [get_staging_version, trigger-github-deployment]
permissions:
contents: read
pull-requests: read
id-token: write
uses: equinor/armada/.github/workflows/run_dotnet_migrations.yml@main
with:
environment: Production
checkout_ref: ${{ needs.get_staging_version.outputs.versionTag }}
working_directory: backend/api
azure_subscription_id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
copy-images-to-robotics-prod-registry:
name: Copy staging images to robotics prod registry
needs: [get_staging_version, trigger-github-deployment]
runs-on: ubuntu-latest
strategy:
matrix:
component: [broker, backend, frontend]
steps:
- name: Log in to robotics staging registry
uses: docker/login-action@v3
with:
registry: roboticsstagingacr.azurecr.io
username: ${{ secrets.ROBOTICS_ROBOTICSSTAGINGACR_USERNAME }}
password: ${{ secrets.ROBOTICS_ROBOTICSSTAGINGACR_PASSWORD }}
- name: Log in to robotics prod registry
uses: docker/login-action@v3
with:
registry: roboticsprodacr.azurecr.io
username: ${{ secrets.ROBOTICS_ROBOTICSPRODACR_USERNAME }}
password: ${{ secrets.ROBOTICS_ROBOTICSPRODACR_PASSWORD }}
- name: Copy image from staging to prod registry
run: |
docker buildx imagetools create \
--tag roboticsprodacr.azurecr.io/robotics/flotilla-${{ matrix.component }}:${{ needs.get_staging_version.outputs.versionTag }} \
--tag roboticsprodacr.azurecr.io/robotics/flotilla-${{ matrix.component }}:latest \
roboticsstagingacr.azurecr.io/robotics/flotilla-${{ matrix.component }}:${{ needs.get_staging_version.outputs.versionTag }}
deploy:
name: Update deployment in Production
needs: [get_staging_version, trigger-github-deployment, copy-images-to-robotics-prod-registry]
strategy:
max-parallel: 1
matrix:
component: [frontend, backend, broker]
uses: equinor/armada/.github/workflows/update_kubernetes_deployment.yml@main
with:
environment: production
tag: ${{ needs.get_staging_version.outputs.versionTag }}
registry: roboticsprodacr.azurecr.io
image_name: robotics/flotilla-${{ matrix.component }}
author_name: ${{ github.actor }}
infrastructure_repository: equinor/robotics-infrastructure
commit_message_service_name: Flotilla
secrets:
deploy_key: ${{ secrets.ROBOTICS_INFRASTRUCTURE_DEPLOY_KEY }}