Skip to content

Commit

Permalink
[SRM-526] Added new ci config to update reference branch. (#21)
Browse files Browse the repository at this point in the history
* [SRM-526] Added new ci config to update reference branch.

* Updated script.

Co-authored-by: Md Nadim Hossain <getovic@gmail.com>
  • Loading branch information
edyuenyw and MdNadimHossain committed Dec 28, 2022
1 parent 0b2c8ad commit c2a3cd5
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 2 deletions.
59 changes: 57 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
version: 2
aliases:
- &ssh_key_fingerprint "36:03:e3:ca:b3:0b:82:18:e2:e9:ae:5d:81:17:86:b1"
# Fingerprint of the SSH deploy key of the project used to pull code.
# The value can be found in CircleCI UI -> SSH Permissions.

- &step_configure_git
run:
name: Configure git
command: |
git config --global user.email "$DEPLOY_USER_EMAIL" && git config --global user.name "$DEPLOY_USER_NAME"
# Re-usable job to run different types of builds.
- &job-build
working_directory: /app
working_directory: &working-directory /app
docker:
- image: &builder-image singledigital/bay-ci-builder:4.x
environment:
Expand All @@ -25,6 +35,35 @@ aliases:
- store_artifacts:
path: /tmp/artifacts

# Job to perform merge to reference branch after a merge to develop.
- &merge-to-reference
working_directory: *working-directory
docker:
- image: *builder-image
auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_PASSWORD
environment:
LAGOON_ENVIRONMENT_TYPE: ci
SSH_KEY_FINGERPRINT: *ssh_key_fingerprint
DEPLOY_USER_EMAIL: sdp.devs@dpc.vic.gov.au
DEPLOY_USER_NAME: sdpdeploy
steps:
- attach_workspace:
at: /workspace
- checkout
- *step_configure_git
- setup_remote_docker:
docker_layer_caching: true
- add_ssh_keys:
fingerprints:
- *ssh_key_fingerprint
- run:
name: Merge to reference branch
command: .circleci/merge-to-reference.sh
no_output_timeout: 30m


jobs:
build:
<<: *job-build
Expand All @@ -38,10 +77,26 @@ jobs:
LAGOON_ENVIRONMENT_TYPE: ci
INSTALL_SUGGEST: 1
BEHAT_PROFILE: "--profile=suggest"

merge_to_reference:
<<: *merge-to-reference


workflows:
version: 2
main:
jobs:
- build
- build_suggest
- build_suggest:
filters:
branches:
ignore:
- reference

mergetoreference:
jobs:
- merge_to_reference:
filters:
branches:
only:
- develop
21 changes: 21 additions & 0 deletions .circleci/merge-to-reference.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
##
# Merge develop to reference branch in CI.
#

echo "==> Checking out reference branch"
git checkout reference
echo "==> Merging develop to reference branch"
git merge develop
git checkout develop -- composer.json
git add .
echo "==> Replacing composer require entries starting with dpc-sdp with value dev-reference"
cat composer.json | gojq '.require |= with_entries(
if (.key | test("dpc-sdp/tide"))
then .value = "dev-reference" end)' > composer.json.backup
mv -f composer.json.backup composer.json
echo "==> Add all changes"
git add .
git commit -m "Merge changes from develop."
echo "==> Push the changes to remote reference branch"
git push origin --force reference

0 comments on commit c2a3cd5

Please sign in to comment.