Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 7 additions & 40 deletions .github/workflows/deploy_to_development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,22 @@ concurrency:
group: development-concurrency
cancel-in-progress: true

on:
push:
branches: [main]

permissions:
contents: read
packages: write

on:
push:
branches:
- "main"

jobs:
get-short-sha:
outputs:
tag: ${{ steps.get-tag.outputs.tag }}
runs-on: ubuntu-latest
steps:
- id: get-tag
run: |
SHA_SHORT=$(echo ${{ github.sha }} | cut -c1-8)
echo "tag=$SHA_SHORT" >> "$GITHUB_OUTPUT"

build-and-push-dev-image-to-ghcr:
name: Build and push dev image to github container registry
needs: get-short-sha
uses: equinor/armada/.github/workflows/build_and_publish_docker_image_to_container_registry.yml@main
permissions:
contents: read
packages: write
with:
registry: roboticsdevacr.azurecr.io
image_name: robotics/sara-utilities
tag: "dev.${{ needs.get-short-sha.outputs.tag }}"
secondary_tag: dev
path_to_dockerfile: Dockerfile
path_to_context: .
secrets:
registry_username: ${{ secrets.ROBOTICS_ROBOTICSDEVACR_USERNAME }}
registry_password: ${{ secrets.ROBOTICS_ROBOTICSDEVACR_PASSWORD }}

deploy:
name: Update deployment in Development
needs: [build-and-push-dev-image-to-ghcr, get-short-sha]
uses: equinor/armada/.github/workflows/update_kubernetes_deployment.yml@main
uses: equinor/armada/.github/workflows/deploy_to_development.yml@main
with:
environment: development
registry: roboticsdevacr.azurecr.io
image_name: robotics/sara-utilities
tag: "dev.${{ needs.get-short-sha.outputs.tag }}"
author_email: ${{ github.event.head_commit.author.email }}
author_name: ${{ github.event.head_commit.author.name }}
infrastructure_repository: equinor/analytics-infrastructure
secrets:
registry_username: ${{ secrets.ROBOTICS_ROBOTICSDEVACR_USERNAME }}
registry_password: ${{ secrets.ROBOTICS_ROBOTICSDEVACR_PASSWORD }}
deploy_key: ${{ secrets.ANALYTICS_INFRASTRUCTURE_DEPLOY_KEY }}
35 changes: 8 additions & 27 deletions .github/workflows/deploy_to_staging.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,27 @@
name: Deploy to Staging

# Only one workflow in a concurrency group may run at a time
concurrency:
group: staging-concurrency
cancel-in-progress: true

permissions:
contents: read
packages: write

on:
release:
types: [published]

permissions:
contents: read
packages: write

jobs:
build-and-push-latest-release-image-to-robotics-staging-container-registry:
name: Build and push latest release image to roboticsstagingacr
uses: equinor/armada/.github/workflows/build_and_publish_docker_image_to_container_registry.yml@main
permissions:
contents: read
packages: write
deploy:
uses: equinor/armada/.github/workflows/deploy_to_staging.yml@main
with:
registry: roboticsstagingacr.azurecr.io
image_name: robotics/sara-utilities
tag: ${{ github.event.release.tag_name }}
secondary_tag: latest
path_to_dockerfile: Dockerfile
path_to_context: .
infrastructure_repository: equinor/analytics-infrastructure
author_name: ${{ github.event.release.author.login }}
secrets:
registry_username: ${{ secrets.ROBOTICS_ROBOTICSSTAGINGACR_USERNAME }}
registry_password: ${{ secrets.ROBOTICS_ROBOTICSSTAGINGACR_PASSWORD }}

update-deployment-in-staging:
name: Update deployment in Staging
needs: build-and-push-latest-release-image-to-robotics-staging-container-registry
uses: equinor/armada/.github/workflows/update_kubernetes_deployment.yml@main
with:
environment: staging
registry: roboticsstagingacr.azurecr.io
image_name: robotics/sara-utilities
tag: ${{ github.event.release.tag_name }}
author_name: ${{ github.event.release.author.login }}
infrastructure_repository: equinor/analytics-infrastructure
secrets:
deploy_key: ${{ secrets.ANALYTICS_INFRASTRUCTURE_DEPLOY_KEY }}
68 changes: 13 additions & 55 deletions .github/workflows/promote_to_production.yml
Original file line number Diff line number Diff line change
@@ -1,70 +1,28 @@
name: Promote to Production

# Only one workflow in a concurrency group may run at a time
concurrency:
group: production-concurrency
cancel-in-progress: true

on:
workflow_dispatch:

jobs:
get_staging_version:
name: Get version from staging
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/analytics-infrastructure
ssh-key: ${{ secrets.ANALYTICS_INFRASTRUCTURE_DEPLOY_KEY }}

- name: Get sara-utilities version in staging
id: get_version_tag
run: |
TAG_LINE_NUMBER=$(($(grep -n "roboticsstagingacr.azurecr.io/robotics/sara-utilities" 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)
echo "tag=$VERSION_TAG" >> "$GITHUB_OUTPUT"

copy-image-to-robotics-prod-registry:
name: Copy staging image to robotics prod registry
needs: get_staging_version
runs-on: ubuntu-latest
steps:
- name: Log in to robotics staging registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 #v4
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@4907a6ddec9925e35a0a9e82d7399ccc52663121 #v4
with:
registry: roboticsprodacr.azurecr.io
username: ${{ secrets.ROBOTICS_ROBOTICSPRODACR_USERNAME }}
password: ${{ secrets.ROBOTICS_ROBOTICSPRODACR_PASSWORD }}
permissions:
contents: read
packages: write

- name: Copy image from staging to prod registry
run: |
docker buildx imagetools create \
--tag roboticsprodacr.azurecr.io/robotics/sara-utilities:${{ needs.get_staging_version.outputs.versionTag }} \
--tag roboticsprodacr.azurecr.io/robotics/sara-utilities:latest \
roboticsstagingacr.azurecr.io/robotics/sara-utilities:${{ needs.get_staging_version.outputs.versionTag }}

deploy:
name: Update deployment in Production
needs: [get_staging_version, copy-image-to-robotics-prod-registry]
uses: equinor/armada/.github/workflows/update_kubernetes_deployment.yml@main
jobs:
promote:
uses: equinor/armada/.github/workflows/promote_to_production.yml@main
with:
environment: production
tag: ${{ needs.get_staging_version.outputs.versionTag }}
registry: roboticsprodacr.azurecr.io
image_name: robotics/sara-utilities
author_name: ${{ github.actor }}
staging_registry: roboticsstagingacr.azurecr.io
production_registry: roboticsprodacr.azurecr.io
infrastructure_repository: equinor/analytics-infrastructure
author_name: ${{ github.actor }}
secrets:
staging_registry_username: ${{ secrets.ROBOTICS_ROBOTICSSTAGINGACR_USERNAME }}
staging_registry_password: ${{ secrets.ROBOTICS_ROBOTICSSTAGINGACR_PASSWORD }}
production_registry_username: ${{ secrets.ROBOTICS_ROBOTICSPRODACR_USERNAME }}
production_registry_password: ${{ secrets.ROBOTICS_ROBOTICSPRODACR_PASSWORD }}
deploy_key: ${{ secrets.ANALYTICS_INFRASTRUCTURE_DEPLOY_KEY }}
Loading