Skip to content

Commit 64ff6d1

Browse files
authored
Merge pull request #301 from digital-gov-mg/develop
Merge Upgrade to v1.6.3
2 parents f36214b + 52303a2 commit 64ff6d1

File tree

19 files changed

+1075
-475
lines changed

19 files changed

+1075
-475
lines changed

.github/workflows/auto-pr-to-release.yml

Lines changed: 121 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,122 @@ on:
1818
description: 'PR number to process'
1919
required: true
2020
default: ''
21+
dry_run:
22+
description: 'Dry run'
23+
required: false
24+
default: false
25+
type: boolean
2126

2227
jobs:
23-
create-pr:
28+
resolve-releases:
2429
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' }}
2530
runs-on: ubuntu-latest
26-
31+
outputs:
32+
matrix: ${{ steps.resolve-applicable-versions.outputs.matrix }}
2733
steps:
2834
- name: Checkout repository
2935
uses: actions/checkout@v4
36+
with:
37+
fetch-depth: 0
3038

3139
- name: Get PR details from workflow dispatch
3240
if: ${{ github.event_name == 'workflow_dispatch' }}
3341
id: get_pr_details_dispatch
3442
run: |
3543
PR_NUMBER=${{ github.event.inputs.pr_number }}
36-
PR_DATA=$(gh pr view $PR_NUMBER --json number,headRefName,baseRefName,mergedBy,mergeCommit,author,milestone,title --jq '{number: .number, headRefName: .headRefName, baseRefName: .baseRefName, merger: .mergedBy.login, author: .author.login, milestone: .milestone.title, title: .title}')
37-
echo "PR_ID=$(echo $PR_DATA | jq -r '.number')" >> $GITHUB_ENV
38-
echo "PR_AUTHOR=$(echo $PR_DATA | jq -r '.author')" >> $GITHUB_ENV
39-
echo "PR_MERGER=$(echo $PR_DATA | jq -r '.merger')" >> $GITHUB_ENV
40-
echo "MILESTONE=$(echo $PR_DATA | jq -r '.milestone')" >> $GITHUB_ENV
41-
echo "BASE_BRANCH=$(echo $PR_DATA | jq -r '.baseRefName')" >> $GITHUB_ENV
42-
echo "HEAD_BRANCH=$(echo $PR_DATA | jq -r '.headRefName')" >> $GITHUB_ENV
43-
echo "PR_TITLE=$(echo $PR_DATA | jq -r '.title')" >> $GITHUB_ENV
44+
PR_DATA=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/opencrvs/opencrvs-countryconfig/pulls/$PR_NUMBER)
45+
echo "MILESTONE=$(printf '%s' $PR_DATA | jq -r '.milestone.title')" >> $GITHUB_ENV
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
4448

45-
LATEST_COMMIT_SHA=$(gh pr view $PR_NUMBER --json commits --jq '.commits[-1].oid')
46-
FIRST_COMMIT_SHA=$(gh pr view $PR_NUMBER --json commits --jq '.commits[0].oid')
47-
echo "LATEST_COMMIT_SHA=${LATEST_COMMIT_SHA}" >> $GITHUB_ENV
48-
echo "FIRST_COMMIT_SHA=${FIRST_COMMIT_SHA}" >> $GITHUB_ENV
49+
- name: Get PR details from event
50+
if: ${{ github.event_name == 'pull_request' }}
51+
id: get_pr_details_event
52+
run: |
53+
echo "MILESTONE=${{ github.event.pull_request.milestone.title }}" >> $GITHUB_ENV
4954
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
56+
57+
- name: Check for milestone and if release branch exists
58+
continue-on-error: true
59+
id: resolve-applicable-versions
60+
run: |
61+
if [ -z "${{ env.MILESTONE }}" ] || [ "${{ env.MILESTONE }}" = "null" ]; then
62+
echo "No milestone set. Exiting."
63+
exit 1
64+
fi
65+
66+
filter_versions() {
67+
local input_version=$1
68+
69+
# List remote branches, extract versions, and sort them semantically
70+
versions=$(git ls-remote --heads origin 'release-*' | awk -F'release-' '{print $2}' | sort -V)
71+
72+
# Filter out versions less than the input version
73+
filtered_versions=$(echo "$versions" | awk -v input="$input_version" '
74+
function compare_versions(v1, v2) {
75+
split(v1, a, /[.v]/);
76+
split(v2, b, /[.v]/);
77+
for (i = 2; i <= 4; i++) {
78+
if (a[i] < b[i]) return -1;
79+
if (a[i] > b[i]) return 1;
80+
}
81+
return 0;
82+
}
83+
{
84+
if (compare_versions($0, input) >= 0) {
85+
print $0
86+
}
87+
}')
88+
89+
# Keep only the highest patch version for each minor version
90+
echo "$filtered_versions" | awk -F. '
91+
{
92+
minor = $1 "." $2;
93+
patches[minor] = $0;
94+
}
95+
END {
96+
for (minor in patches) {
97+
print patches[minor];
98+
}
99+
}' | sort -V
100+
}
101+
102+
versions=$(filter_versions "${{ env.MILESTONE }}")
103+
json_array=$(echo "$versions" | jq -R -s -c 'split("\n") | map(select(. != ""))')
104+
echo "matrix=$json_array" >> $GITHUB_OUTPUT
105+
106+
create-pr:
107+
needs: resolve-releases
108+
runs-on: ubuntu-22.04
109+
if: ${{ always() && needs.resolve-releases.result == 'success' }}
110+
111+
strategy:
112+
fail-fast: false
113+
matrix:
114+
version: ${{fromJson(needs.resolve-releases.outputs.matrix)}}
115+
116+
steps:
117+
- name: Checkout repository
118+
uses: actions/checkout@v4
119+
120+
- name: Get PR details from workflow dispatch
121+
if: ${{ github.event_name == 'workflow_dispatch' }}
122+
id: get_pr_details_dispatch
123+
run: |
124+
PR_NUMBER=${{ github.event.inputs.pr_number }}
125+
PR_DATA=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/opencrvs/opencrvs-countryconfig/pulls/$PR_NUMBER)
126+
# printf escapes the newlines in the JSON, so we can use jq to parse output such as:
127+
# "body": "![image](https://github.com/user-attachments/assets/8eee5bcf-7692-490f-a19f-576623e09961)\r\n",
128+
echo "PR_ID=$(printf '%s' $PR_DATA | jq -r '.number')" >> $GITHUB_ENV
129+
echo "PR_AUTHOR=$(printf '%s' $PR_DATA | jq -r '.user.login')" >> $GITHUB_ENV
130+
echo "PR_MERGER=$(printf '%s' $PR_DATA | jq -r '.merged_by.login')" >> $GITHUB_ENV
131+
echo "BASE_BRANCH=$(printf '%s' $PR_DATA | jq -r '.base.ref')" >> $GITHUB_ENV
132+
echo "HEAD_BRANCH=$(printf '%s' $PR_DATA | jq -r '.head.ref')" >> $GITHUB_ENV
133+
echo "PR_TITLE=$(printf '%s' $PR_DATA | jq -r '.title')" >> $GITHUB_ENV
134+
echo "BASE_SHA=$(printf '%s' $PR_DATA | jq -r '.base.sha')" >> $GITHUB_ENV
135+
env:
136+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
51137

52138
- name: Get PR details from event
53139
if: ${{ github.event_name == 'pull_request' }}
@@ -56,7 +142,6 @@ jobs:
56142
PR_NUMBER=${{ github.event.pull_request.number }}
57143
echo "PR_ID=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
58144
echo "PR_AUTHOR=${{ github.event.pull_request.user.login }}" >> $GITHUB_ENV
59-
echo "MILESTONE=${{ github.event.pull_request.milestone.title }}" >> $GITHUB_ENV
60145
echo "BASE_BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
61146
echo "HEAD_BRANCH=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
62147
echo "PR_TITLE=${{ github.event.pull_request.title }}" >> $GITHUB_ENV
@@ -70,52 +155,36 @@ jobs:
70155
MERGED_BY_LOGIN=$(echo "$PR_DETAILS" | jq -r '.mergedBy.login')
71156
echo "PR_MERGER=$MERGED_BY_LOGIN" >> $GITHUB_ENV
72157
env:
73-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74-
75-
- name: Check for milestone and if release branch exists
76-
continue-on-error: true
77-
id: check_release_branch
78-
run: |
79-
if [ -z "${{ env.MILESTONE }}" ]; then
80-
echo "No milestone set. Exiting."
81-
exit 1
82-
fi
83-
84-
RELEASE_BRANCH="release-${{ env.MILESTONE }}"
85-
86-
# Check if the release branch exists
87-
if git ls-remote --heads origin $RELEASE_BRANCH | grep -q "refs/heads/$RELEASE_BRANCH"; then
88-
echo "RELEASE_BRANCH=${RELEASE_BRANCH}" >> $GITHUB_ENV
89-
else
90-
echo "Release branch $RELEASE_BRANCH does not exist. Exiting."
91-
exit 1
92-
fi
158+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
93159

94160
- name: Create and push the new branch for the PR
95-
if: ${{ steps.check_release_branch.outcome == 'success' }}
161+
env:
162+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
96163
run: |
97164
SEMANTIC_PR_TITLE="${{ env.PR_TITLE }}"
165+
RELEASE_BRANCH="release-${{ matrix.version }}"
166+
MILESTONE="${{ matrix.version }}"
98167
99168
# Check for semantic prefix
100169
if [[ $SEMANTIC_PR_TITLE =~ ^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert|wip|merge)\: ]]; then
101170
SEMANTIC_PR_TITLE="${BASH_REMATCH[1]}(${MILESTONE}): ${SEMANTIC_PR_TITLE#*: }"
102171
else
103-
SEMANTIC_PR_TITLE="🍒 Merge changes from PR #${{ env.PR_ID }} to ${{ env.RELEASE_BRANCH }}"
172+
SEMANTIC_PR_TITLE="🍒 Merge changes from PR #${{ env.PR_ID }} to $RELEASE_BRANCH"
104173
fi
105174
106-
PR_BODY="Automated PR to merge changes from develop to ${{ env.RELEASE_BRANCH }}"
175+
PR_BODY="Automated PR to merge changes from develop to $RELEASE_BRANCH"
107176
108177
# Configure git
109178
git config user.name "github-actions"
110179
git config user.email "[email protected]"
111180
git config advice.mergeConflict false
112181
113182
# Fetch and checkout the release branch
114-
git fetch --all
115-
git checkout ${{ env.RELEASE_BRANCH }}
183+
git fetch --all --unshallow
184+
git checkout $RELEASE_BRANCH
116185
117186
# Create a new branch for the PR
118-
NEW_BRANCH="auto-pr-${{ env.RELEASE_BRANCH }}-${{ env.PR_ID }}-$RANDOM"
187+
NEW_BRANCH="auto-pr-$RELEASE_BRANCH-${{ env.PR_ID }}-$RANDOM"
119188
git checkout -b $NEW_BRANCH
120189
121190
echo "First commit: ${{ env.FIRST_COMMIT_SHA }}"
@@ -167,6 +236,15 @@ jobs:
167236
"
168237
}
169238
239+
if [ "${{ github.event.inputs.dry_run }}" == "true" ]; then
240+
echo "This is a dry run."
241+
echo "Would have pushed the new branch $NEW_BRANCH"
242+
echo "PR title: $SEMANTIC_PR_TITLE"
243+
echo "PR body:"
244+
echo "$PR_BODY"
245+
exit 0
246+
fi
247+
170248
# Push the new branch
171249
git push origin $NEW_BRANCH
172250
@@ -180,6 +258,4 @@ jobs:
180258
AUTHOR=${{ env.PR_MERGER }}
181259
fi
182260
fi
183-
gh pr create --title "$SEMANTIC_PR_TITLE" --body "$PR_BODY" --head "$NEW_BRANCH" --base "${{ env.RELEASE_BRANCH }}" --assignee "$AUTHOR" --reviewer "$AUTHOR"
184-
env:
185-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
261+
gh pr create --title "$SEMANTIC_PR_TITLE" --body "$PR_BODY" --head "$NEW_BRANCH" --base "$RELEASE_BRANCH" --assignee "$AUTHOR" --reviewer "$AUTHOR"

.github/workflows/deploy-prod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
core-image-tag:
1515
description: Core DockerHub image tag
1616
required: true
17-
default: 'v1.6.0'
17+
default: 'v1.6.3'
1818
countryconfig-image-tag:
1919
description: Your Country Config DockerHub image tag
2020
required: true

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
core-image-tag:
1616
description: Core DockerHub image tag
1717
required: true
18-
default: 'v1.6.0'
18+
default: 'v1.6.3'
1919
countryconfig-image-tag:
2020
description: Your Country Config DockerHub image tag
2121
required: true

CHANGELOG.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
# Changelog
22

3-
## 1.6.0 (TBD)
3+
## 1.6.3
4+
5+
### Breaking changes
6+
7+
- Add constant.humanName to allow countries to customise the format of the full name in the sytem for `sytem users` and `citizens` e.g `{LastName} {MiddleName} {Firstname}`, in any case where one of the name is not provided e.g no `MiddleName`, we'll simply render e.g `{LastName} {FirstName}` without any extra spaces if that's the order set in `country-config`. [#6830](https://github.com/opencrvs/opencrvs-core/issues/6830)
8+
9+
## 1.6.2
10+
11+
## 1.6.1
12+
13+
### Bug fixes
14+
15+
- We make sure that the automatic cleanup job only runs before deployment (instead of cron schedule cleanup).
16+
- Previously it was possible MongoDB replica set and users were left randomly uninitialised after a deployment. MongoDB initialisation container now retries on failure.
17+
- On some machines 'file' utility was not preinstalled causing provision to fail. We now install the utility if it doesn't exist.
18+
19+
## 1.6.0
420

521
### Breaking changes
622

@@ -40,6 +56,7 @@
4056
- You can now configure the home screen application’s name and icons in your country configuration package as manifest.json and app icon files are moved from core to country config (check `src/client-static` folder)
4157
- Updated `allowedFileFormats` in signature fields to use MIME types (`image/png`, `image/jpg`, `image/jpeg`, `image/svg`) instead of simple file extensions. If you are already using the `allowedFileFormats` field in your implementation, please ensure to update the format accordingly.
4258
- Remove unnecessary UI dividers that add in various sections of the declaration forms(e.g the Death, Birth and Marriage forms) [#244](https://github.com/opencrvs/opencrvs-countryconfig/pull/244)
59+
- The details exists conditionals for the various sections i.e. father, mother, spouse has to use the `values.detailsExist` property instead of accessing it from `draftData.[sectionName].detailsExists`. This is due to the fact that the draftData is not populated until any changes have been made to any of the fields in the current section.
4360

4461
### Bug fixes
4562

@@ -77,6 +94,14 @@ INSERT CSV ROWS IN ENGLISH ONLY
7794

7895
- Github pipeline dedicated for reading secrets and variables from other environments now checks if GH_TOKEN is still valid before attempting other operations
7996
- Remove unnecessary UI dividers that add in various sections of the declaration forms(e.g the Death, Birth and Marriage forms) [#244](https://github.com/opencrvs/opencrvs-countryconfig/pull/244)
97+
- Update template transformer for fields `informantType` and `otherInformantType` that fixes the bug of unavailability of these template fields [#5952](https://github.com/opencrvs/opencrvs-countryconfig/pull/5952)
98+
- Fixed missing InitialValue property to set initial values based on an expression
99+
100+
## 1.5.2 (https://github.com/opencrvs/opencrvs-countryconfig/compare/v1.5.1...v1.5.2)
101+
102+
## Bug fixes
103+
104+
- Broken email alerts from low disk space are now fixed [293](https://github.com/opencrvs/opencrvs-countryconfig/pull/293)
80105

81106
## 1.5.0 (https://github.com/opencrvs/opencrvs-countryconfig/compare/v1.4.1...v1.5.0)
82107

infrastructure/deployment/deploy.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,11 @@ split_and_join() {
268268
SPLIT=$(echo $text | sed -e "s/$separator_for_splitting/$separator_for_joining/g")
269269
echo $SPLIT
270270
}
271+
cleanup_docker_images()
272+
{
273+
echo "Cleaning up the docker images"
274+
configured_ssh "/usr/bin/docker system prune -af | sudo tee -a /var/log/docker-prune.log > /dev/null"
275+
}
271276

272277
docker_stack_deploy() {
273278
echo "Deploying this environment: $ENVIRONMENT_COMPOSE"
@@ -407,6 +412,8 @@ configured_ssh "/opt/opencrvs/infrastructure/setup-deploy-config.sh $HOST"
407412

408413
rotate_secrets
409414

415+
cleanup_docker_images
416+
410417
docker_stack_deploy
411418

412419
echo

infrastructure/docker-compose.deploy.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,11 @@ services:
226226
labels:
227227
- traefik.enable=false
228228
replicas: 1
229+
# If this doesn't get run successfully, both the replica set in mongo and
230+
# the user schema remains uninitialized.
229231
restart_policy:
230-
condition: none
232+
condition: on-failure
233+
delay: 10s
231234
environment:
232235
- REPLICAS=1
233236
- MONGODB_ADMIN_USER=${MONGODB_ADMIN_USER}

infrastructure/monitoring/elastalert/rules/alert.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ filter:
2626
should:
2727
- term:
2828
rule.name.keyword:
29-
value: 'Available disk space in data partition'
29+
value: 'Available disk space in root file system'
3030
- term:
3131
rule.name.keyword:
3232
value: 'CPU under heavy load'
3333
- term:
3434
rule.name.keyword:
35-
value: 'Low on available disk space'
35+
value: 'Low on available disk space in data partition'
3636
minimum_should_match: 1
3737

3838
alert: post2

infrastructure/server-setup/tasks/docker.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@
4545
cron:
4646
user: '{{ crontab_user }}'
4747
name: 'cleanup docker images'
48-
minute: '0'
49-
hour: '0'
5048
job: '/usr/bin/docker system prune -af >> /var/log/docker-prune.log'
49+
state: absent
5150

5251
- name: Check if Docker group exists
5352
command: getent group docker

infrastructure/server-setup/tasks/swap.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
tags:
1515
- swap.file.permissions
1616

17+
- name: Ensure 'file' utility is installed
18+
ansible.builtin.package:
19+
name: file
20+
state: present
21+
tags:
22+
- swap.file.mkswap
23+
1724
- name: 'Check swap file type'
1825
command: file {{ swap_file_path }}
1926
register: swapfile

0 commit comments

Comments
 (0)