diff --git a/.github/workflows/deploy_to_development.yml b/.github/workflows/deploy_to_development.yml index 255326a..93e23b2 100644 --- a/.github/workflows/deploy_to_development.yml +++ b/.github/workflows/deploy_to_development.yml @@ -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 }} diff --git a/.github/workflows/deploy_to_staging.yml b/.github/workflows/deploy_to_staging.yml index bec608b..6d32e1f 100644 --- a/.github/workflows/deploy_to_staging.yml +++ b/.github/workflows/deploy_to_staging.yml @@ -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 }} diff --git a/.github/workflows/promote_to_production.yml b/.github/workflows/promote_to_production.yml index d3d3a3e..c2c3cb3 100644 --- a/.github/workflows/promote_to_production.yml +++ b/.github/workflows/promote_to_production.yml @@ -1,6 +1,5 @@ name: Promote to Production -# Only one workflow in a concurrency group may run at a time concurrency: group: production-concurrency cancel-in-progress: true @@ -8,63 +7,22 @@ concurrency: 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 }}