diff --git a/.github/workflows/deploy_to_development.yml b/.github/workflows/deploy_to_development.yml index 7948739..738c236 100644 --- a/.github/workflows/deploy_to_development.yml +++ b/.github/workflows/deploy_to_development.yml @@ -1,64 +1,28 @@ name: Deploy to Development -# Only one workflow in a concurrency group may run at a time concurrency: group: development-concurrency cancel-in-progress: true -permissions: - contents: read - packages: write - on: push: - branches: - - "main" + branches: [main] paths-ignore: - "train/**" -jobs: - trigger-github-deployment: - name: Trigger GitHub Deployment - environment: Development - runs-on: ubuntu-latest - steps: - - name: Empty Step - run: echo "Hello World" - - get-short-sha: - needs: trigger-github-deployment - 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-components-to-ghcr: - name: Build and push containers to github container registry for Development - needs: [trigger-github-deployment, get-short-sha] - uses: ./.github/workflows/publish_component.yml - with: - Registry: roboticsdevacr.azurecr.io - ImageName: robotics/sara-thermal-reading - Tag: "dev.${{ needs.get-short-sha.outputs.tag }}" - secrets: - RegistryUsername: ${{ secrets.ROBOTICS_ROBOTICSDEVACR_USERNAME }} - RegistryPassword: ${{ secrets.ROBOTICS_ROBOTICSDEVACR_PASSWORD }} +permissions: + contents: read + packages: write +jobs: deploy: - name: Update deployment in Development - needs: [build-and-push-components-to-ghcr, get-short-sha, trigger-github-deployment] - 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-thermal-reading - 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 + environment_name: Development 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 67d5f3f..ccfa3c6 100644 --- a/.github/workflows/deploy_to_staging.yml +++ b/.github/workflows/deploy_to_staging.yml @@ -1,40 +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] -jobs: - build-and-push-release-to-robotics-staging-registry: - name: Build and push containers to roboticsstagingacr for Staging - uses: ./.github/workflows/publish_component.yml - with: - Registry: roboticsstagingacr.azurecr.io - ImageName: robotics/sara-thermal-reading - Tag: ${{ github.event.release.tag_name }} - secrets: - RegistryUsername: ${{ secrets.ROBOTICS_ROBOTICSSTAGINGACR_USERNAME }} - RegistryPassword: ${{ secrets.ROBOTICS_ROBOTICSSTAGINGACR_PASSWORD }} +permissions: + contents: read + packages: write +jobs: deploy: - name: Update deployment in Staging - needs: [build-and-push-release-to-robotics-staging-registry] - uses: equinor/armada/.github/workflows/update_kubernetes_deployment.yml@main + uses: equinor/armada/.github/workflows/deploy_to_staging.yml@main with: - environment: staging registry: roboticsstagingacr.azurecr.io image_name: robotics/sara-thermal-reading tag: ${{ github.event.release.tag_name }} - author_name: ${{ github.event.release.author.login }} 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 }} deploy_key: ${{ secrets.ANALYTICS_INFRASTRUCTURE_DEPLOY_KEY }} diff --git a/.github/workflows/promote_to_production.yml b/.github/workflows/promote_to_production.yml index 2ee2dd5..58c73b3 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 Thermal Reading version in staging - id: get_version_tag - run: | - TAG_LINE_NUMBER=$(($(grep -n "roboticsstagingacr.azurecr.io/robotics/sara-thermal-reading" 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-thermal-reading:${{ needs.get_staging_version.outputs.versionTag }} \ - --tag roboticsprodacr.azurecr.io/robotics/sara-thermal-reading:latest \ - roboticsstagingacr.azurecr.io/robotics/sara-thermal-reading:${{ 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-thermal-reading - 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 }} diff --git a/.github/workflows/publish_component.yml b/.github/workflows/publish_component.yml deleted file mode 100644 index e4770a0..0000000 --- a/.github/workflows/publish_component.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Build and publish component - -on: - workflow_call: - inputs: - Registry: - required: true - type: string - Tag: - required: true - type: string - ImageName: - required: true - type: string - secrets: - RegistryUsername: - required: true - RegistryPassword: - required: true - -jobs: - build-and-push-container: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - name: Checkout repository - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6 - - - name: Log in to the Github Container registry - uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 #v4 - with: - registry: ${{ inputs.Registry }} - username: ${{ secrets.RegistryUsername }} - password: ${{ secrets.RegistryPassword }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf #v6 - with: - images: ${{ inputs.Registry }}/${{ inputs.ImageName }} - - - name: Build and push Docker image - uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 #v7 - with: - context: . - push: true - tags: | - ${{ inputs.Registry }}/${{ inputs.ImageName }}:${{ inputs.Tag }} - ${{ inputs.Registry }}/${{ inputs.ImageName }}:latest - labels: ${{ steps.meta.outputs.labels }}