Skip to content

Commit

Permalink
fix: or-2282 update flow to build and deploy from devops account
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Lesage committed Aug 7, 2024
1 parent 8b924b5 commit 12adb20
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 261 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
shell: bash
run: docker image save $BUILD_DOCKER_REGISTRY/organisation-registry/${{ inputs.image-name }}:$SEMVER -o ~/${{ inputs.image-file}}
env:
BUILD_DOCKER_REGISTRY: ${{ secrets.VBR_BUILD_DOCKER_REGISTRY }}
BUILD_DOCKER_REGISTRY: ${{ secrets.VBR_DEVOPS_DOCKER_REGISTRY }}
SEMVER: ${{ inputs.semver }}

- name: Upload artifact
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-site-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
shell: bash
run: docker image save $BUILD_DOCKER_REGISTRY/organisation-registry/${{ inputs.image-name }}:$SEMVER -o ~/${{ inputs.image-file}}
env:
BUILD_DOCKER_REGISTRY: ${{ secrets.VBR_BUILD_DOCKER_REGISTRY }}
BUILD_DOCKER_REGISTRY: ${{ secrets.VBR_DEVOPS_DOCKER_REGISTRY }}
SEMVER: ${{ inputs.semver }}

- name: Upload artifact
Expand Down
197 changes: 32 additions & 165 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
version: ${{ steps.set-version.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node.js
uses: ./.github/actions/setup-nodejs
Expand Down Expand Up @@ -75,14 +75,10 @@ jobs:
- 9200:9200
- 9600:9600

outputs:
version: ${{ steps.set-version.outputs.version }}
test: "test"

steps:

- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup .NET Core
uses: ./.github/actions/setup-dotnet
Expand Down Expand Up @@ -241,7 +237,7 @@ jobs:
- set-release-version

outputs:
version: ${{ steps.set-version.outputs.version }}
version: ${{ needs.set-release-version.outputs.version }}

steps:

Expand Down Expand Up @@ -306,14 +302,15 @@ jobs:
echo ${{ steps.set-version.outputs.version }}
echo 'END VERSION'
publish_to_atlassian:
if: needs.release.outputs.version != 'none'
needs: [ release ]
name: Publish to Atlassian
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Parse repository name
run: echo REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") >> $GITHUB_ENV
Expand Down Expand Up @@ -346,130 +343,6 @@ jobs:
JIRA_PROJECT: OR
JIRA_VERSION: ${{ needs.release.outputs.version }}

push_images_to_staging:
if: needs.release.outputs.version != 'none'
needs: [ release ]
name: Push images to Staging
runs-on: ubuntu-latest
strategy:
matrix:
image: [
'api',
'batch-agentschapzorgengezondheidftpdump',
'batch-vlaanderenbe',
'projections-elasticsearch',
'projections-delegations',
'projections-reporting',
'kbo-mutations',
'ui'
]
steps:
- name: Configure AWS credentials (Staging)
if: needs.release.outputs.version != 'none'
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
aws-access-key-id: ${{ secrets.VBR_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.VBR_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.VBR_AWS_REGION }}

- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v2

- name: Download artifact
uses: actions/download-artifact@v4
continue-on-error: false
with:
name: ${{ matrix.image }}
path: ~/artifacts

- name: Show images
shell: bash
run: docker images

- name: Load artifact
shell: bash
run: |
docker image load -i ~/artifacts/$IMAGE.tar
env:
IMAGE: ${{ matrix.image }}

- name: Show images
shell: bash
run: docker images

- name: Push artifacts to ECR
shell: bash
run: |
echo $IMAGE:$SEMVER
docker push $BUILD_DOCKER_REGISTRY/organisation-registry/$IMAGE:$SEMVER
env:
BUILD_DOCKER_REGISTRY: ${{ secrets.VBR_BUILD_DOCKER_REGISTRY }}
IMAGE: ${{ matrix.image }}
SEMVER: ${{ needs.release.outputs.version }}
WORKSPACE: ${{ github.workspace }}

push_images_to_production:
if: needs.release.outputs.version != 'none'
needs: [ release ]
name: Push images to Production
runs-on: ubuntu-latest
strategy:
matrix:
image: [
'api',
'batch-agentschapzorgengezondheidftpdump',
'batch-vlaanderenbe',
'projections-elasticsearch',
'projections-delegations',
'projections-reporting',
'kbo-mutations',
'ui'
]
steps:
- name: Configure AWS credentials (Production)
if: needs.release.outputs.version != 'none'
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
aws-access-key-id: ${{ secrets.VBR_AWS_ACCESS_KEY_ID_PRD }}
aws-secret-access-key: ${{ secrets.VBR_AWS_SECRET_ACCESS_KEY_PRD }}
aws-region: ${{ secrets.VBR_AWS_REGION_PRD }}

- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v2

- name: Download artifact
uses: actions/download-artifact@v4
continue-on-error: false
with:
name: ${{ matrix.image }}
path: ~/artifacts

- name: Show images
shell: bash
run: docker images

- name: Load artifact
shell: bash
run: |
docker image load -i ~/artifacts/$IMAGE.tar
env:
IMAGE: ${{ matrix.image }}

- name: Show images
shell: bash
run: docker images

- name: Push artifacts to ECR
shell: bash
run: |
echo $IMAGE:$SEMVER
docker push $BUILD_DOCKER_REGISTRY/organisation-registry/$IMAGE:$SEMVER
env:
BUILD_DOCKER_REGISTRY: ${{ secrets.VBR_BUILD_DOCKER_REGISTRY_PRD }}
IMAGE: ${{ matrix.image }}
SEMVER: ${{ needs.release.outputs.version }}
WORKSPACE: ${{ github.workspace }}

push_images_to_devops:
if: needs.release.outputs.version != 'none'
needs: [ release ]
Expand Down Expand Up @@ -524,59 +397,54 @@ jobs:
shell: bash
run: |
echo $IMAGE:$SEMVER
docker image tag $SOURCE_DOCKER_REGISTRY/organisation-registry/$IMAGE:$SEMVER $DESTINATION_DOCKER_REGISTRY/organisation-registry/$IMAGE:$SEMVER
docker push $DESTINATION_DOCKER_REGISTRY/organisation-registry/$IMAGE:$SEMVER
docker push $BUILD_DOCKER_REGISTRY/organisation-registry/$IMAGE:$SEMVER
env:
SOURCE_DOCKER_REGISTRY: ${{ secrets.VBR_BUILD_DOCKER_REGISTRY }}
DESTINATION_DOCKER_REGISTRY: ${{ secrets.VBR_DEVOPS_DOCKER_REGISTRY }}
BUILD_DOCKER_REGISTRY: ${{ secrets.VBR_DEVOPS_DOCKER_REGISTRY }}
IMAGE: ${{ matrix.image }}
SEMVER: ${{ needs.release.outputs.version }}
WORKSPACE: ${{ github.workspace }}

deploy_staging:
deploy_staging_services:
if: needs.release.outputs.version != 'none'
needs: [ release, push_images_to_staging ]
name: Deploy to Staging
needs: [ release, push_images_to_devops ]
name: Deploy to Staging NEW
runs-on: ubuntu-latest
strategy:
matrix:
image: [
'organisation-registry-api',
'organisation-registry-delegations',
'organisation-registry-elasticsearch',
'organisation-registry-kbomutations',
'organisation-registry-reporting',
'organisation-registry-ui',
'organisation-registry-vlaanderenbe',
'organisation-registry-zorgengezondheid',
'organisation-registry-rebuilder'
]
services:
[
'organisation-api',
'organisation-elasticsearch',
'organisation-rebuilder',
'organisation-ui',
]
steps:
- name: CD
id: awscurl-polling-action
env:
BUILD_URL: ${{ secrets.VBR_AWS_BUILD_API }}/${{matrix.services}}
STATUS_URL: ${{ secrets.VBR_AWS_BUILD_STATUS_API }}/${{matrix.services}}
BUILD_URL: ${{ vars.VBR_AWS_BUILD_API_DEVOPS }}/${{matrix.services}}
STATUS_URL: ${{ vars.VBR_AWS_BUILD_STATUS_API_DEVOPS }}/${{matrix.services}}
uses: informatievlaanderen/awscurl-polling-action/polling-action@main
with:
environment: stg
version: ${{ github.event.inputs.version }}
status-url: $STATUS_URL
deploy-url: $BUILD_URL
access-key: ${{ secrets.VBR_AWS_BUILD_USER_ACCESS_KEY_ID }}
secret-key: ${{ secrets.VBR_AWS_BUILD_USER_SECRET_ACCESS_KEY }}
access-key: ${{ secrets.VBR_AWS_ACCESS_KEY_ID_DEVOPS }}
secret-key: ${{ secrets.VBR_AWS_SECRET_ACCESS_KEY_DEVOPS }}
interval: 2
deploy-target: 'agb_ecs_service'
domain: 'basisregisters'
project: 'basisregisters'

- name: output
shell: bash
run: |
echo build-uuid: ${{ steps.awscurl-polling-action.outputs.build-uuid }}
echo Status: ${{ steps.awscurl-polling-action.outputs.status }}
echo ${{ steps.awscurl-polling-action.outputs.final-message }}
deploy_staging_new:
deploy_staging_scheduledtasks:
if: needs.release.outputs.version != 'none'
needs: [ release, push_images_to_devops ]
name: Deploy to Staging NEW
Expand All @@ -585,10 +453,11 @@ jobs:
matrix:
services:
[
'organisation-api',
'organisation-elasticsearch',
'organisation-rebuilder',
'organisation-ui',
'organisation-delegations',
'organisation-kbomutations',
'organisation-reporting',
'organisation-vlaanderenbe',
'organisation-zorgengezondheid',
]
steps:
- name: CD
Expand All @@ -605,7 +474,7 @@ jobs:
access-key: ${{ secrets.VBR_AWS_ACCESS_KEY_ID_DEVOPS }}
secret-key: ${{ secrets.VBR_AWS_SECRET_ACCESS_KEY_DEVOPS }}
interval: 2
deploy-target: 'agb_ecs_service'
deploy-target: 'ecs_scheduled_task'
domain: 'basisregisters'
project: 'basisregisters'

Expand All @@ -616,8 +485,6 @@ jobs:
echo Status: ${{ steps.awscurl-polling-action.outputs.status }}
echo ${{ steps.awscurl-polling-action.outputs.final-message }}
# - name: Publish to NuGet
# shell: bash
# run: |
Expand Down
46 changes: 0 additions & 46 deletions .github/workflows/production-manual.yml

This file was deleted.

Loading

0 comments on commit 12adb20

Please sign in to comment.