Skip to content

Commit 1ff1816

Browse files
authored
Merge pull request #10 from bcgov-nr/feat/composerUpdates
feat: latest composer updates
2 parents 7e58c2c + ba5bd58 commit 1ff1816

File tree

8 files changed

+91
-54
lines changed

8 files changed

+91
-54
lines changed

.github/workflows/build-release.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ env:
2020
SERVICE_NAME: nodejs-sample
2121

2222
jobs:
23-
check_token_expiration:
23+
check-token-expiration:
24+
name: Check token expiration
2425
uses: ./.github/workflows/check-token.yaml
26+
permissions: {}
2527
secrets:
2628
token: ${{ secrets.broker_jwt_BFB8F8BC_D617_484A_9A4E_E9B98AB4E5BC }}
2729
build-release:
2830
name: Build and release
2931
runs-on: ubuntu-latest
30-
needs: check_token_expiration
32+
needs: check-token-expiration
3133
permissions:
3234
contents: read
3335
packages: write

.github/workflows/check-token.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414

1515
jobs:
1616
check-jwt:
17+
name: Check broker token
1718
runs-on: ubuntu-latest
1819

1920
steps:

.github/workflows/deploy.yaml

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,20 @@ env:
2020
PACKAGE_REPO: ghcr.io/${{ github.repository }}/package
2121

2222
jobs:
23-
check_token_expiration:
23+
check-token-expiration:
24+
name: Check token expiration
2425
uses: ./.github/workflows/check-token.yaml
26+
permissions: {}
2527
secrets:
2628
token: ${{ secrets.broker_jwt_BFB8F8BC_D617_484A_9A4E_E9B98AB4E5BC }}
27-
deploy-build:
28-
name: Deploy development version
29+
deploy-pre-release-build:
30+
name: Trigger dev/test deployment
2931
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
3032
runs-on: ubuntu-latest
31-
needs: check_token_expiration
33+
needs: check-token-expiration
34+
permissions:
35+
contents: read
36+
packages: read
3237
outputs:
3338
project_version: ${{ steps.set-build-output.outputs.project_version }}
3439
build_guid: ${{ steps.set-build-output.outputs.build_guid }}
@@ -80,11 +85,14 @@ jobs:
8085
env:
8186
PACKAGE_TAG: ${{ github.ref_name }}
8287
PACKAGE_REPO: ${{ env.PACKAGE_REPO }}
83-
deploy-tag:
84-
name: Deploy release version
88+
deploy-release-build:
89+
name: Trigger prod deployment
8590
if: ${{ startsWith(github.ref, 'refs/tags/') }}
8691
runs-on: ubuntu-latest
87-
needs: check_token_expiration
92+
needs: check-token-expiration
93+
permissions:
94+
contents: read
95+
packages: read
8896
outputs:
8997
project_version: ${{ steps.set-tag-output.outputs.project_version }}
9098
build_guid: ${{ steps.set-tag-output.outputs.build_guid }}
@@ -137,16 +145,21 @@ jobs:
137145
env:
138146
PACKAGE_TAG: ${{ steps.set-tag-output.outputs.project_tag }}
139147
PACKAGE_REPO: ${{ env.PACKAGE_REPO }}
140-
submit-job:
141-
name: Submit job
148+
submit-deployment-job:
149+
name: Submit deployment job
142150
if: |
143151
always() &&
144-
((needs.deploy-build.result == 'success' && needs.deploy-tag.result == 'skipped') ||
145-
(needs.deploy-build.result == 'skipped' && needs.deploy-tag.result == 'success'))
146-
needs: [deploy-build, deploy-tag]
152+
((needs.deploy-pre-release-build.result == 'success' && needs.deploy-release-build.result == 'skipped') ||
153+
(needs.deploy-pre-release-build.result == 'skipped' && needs.deploy-release-build.result == 'success'))
154+
needs: [deploy-pre-release-build, deploy-release-build]
155+
permissions:
156+
actions: read
157+
packages: read
158+
contents: read
147159
runs-on: ubuntu-latest
148160
steps:
149-
- name: Submit a job to Jenkins
161+
# See: https://github.com/bcgov-nr/polaris-pipelines
162+
- name: Submit deployment job
150163
run: |
151164
curl \
152165
--data-urlencode "token=${{ secrets.JENKINS_TOKEN }}" \
@@ -163,13 +176,15 @@ jobs:
163176
-H "Connection: close" \
164177
${{ env.URL }}/${{ env.JOB }}
165178
env:
166-
PROJECT_VERSION: ${{ needs.deploy-build.outputs.project_version || needs.deploy-tag.outputs.project_version }}
167-
BUILD_GUID: ${{ needs.deploy-build.outputs.build_guid || needs.deploy-tag.outputs.build_guid }}
168-
BUILD_NUMBER: ${{ needs.deploy-build.outputs.build_number || needs.deploy-tag.outputs.build_number }}
169-
ARTIFACT_SHA256: ${{ needs.deploy-build.outputs.artifact_sha256 || needs.deploy-tag.outputs.artifact_sha256 }}
170-
DOWNLOAD_URL: ${{ needs.deploy-build.outputs.download_url || needs.deploy-tag.outputs.download_url }}
171-
# The automatically generated GitHub token will expire when the workflow ends. We need to wait so the job has time to clone the repo
172-
# and download the package
173-
- name: Sleep
179+
PROJECT_VERSION: ${{ needs.deploy-pre-release-build.outputs.project_version || needs.deploy-release-build.outputs.project_version }}
180+
BUILD_GUID: ${{ needs.deploy-pre-release-build.outputs.build_guid || needs.deploy-release-build.outputs.build_guid }}
181+
BUILD_NUMBER: ${{ needs.deploy-pre-release-build.outputs.build_number || needs.deploy-release-build.outputs.build_number }}
182+
ARTIFACT_SHA256: ${{ needs.deploy-pre-release-build.outputs.artifact_sha256 || needs.deploy-release-build.outputs.artifact_sha256 }}
183+
DOWNLOAD_URL: ${{ needs.deploy-pre-release-build.outputs.download_url || needs.deploy-release-build.outputs.download_url }}
184+
- name: Display deployment job URL
185+
run: |
186+
DEPLOYMENT_JOB_URL="${{ env.URL }}/job/${{ env.SERVICE_PROJECT }}/job/${{ env.SERVICE_NAME }}/"
187+
echo "Deployment job URL: ${DEPLOYMENT_JOB_URL}"
188+
- name: Keep GH token alive
174189
run: sleep 90s
175190
shell: bash

playbooks/playbook.yaml

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: hello/vvsddsv
2+
- name: nodejs-sample/nodejs-sample
33
hosts: "{{ tomcat_server_hosts }}"
44
collections:
55
- polaris.deploy
@@ -11,17 +11,45 @@
1111

1212
roles:
1313
# prepare the installation environment by creating the necessary folders
14-
- name: create_project_directories
14+
# See: https://github.com/bcgov/nr-polaris-collection/tree/main/polaris/deploy/roles/create_project_directories
15+
- role: create_project_directories
1516

1617
# Establish the port number
17-
- name: port_manager
18+
# See: https://github.com/bcgov/nr-polaris-collection/tree/main/polaris/deploy/roles/port_manager
19+
- role: port_manager
1820

19-
# install & configure the Tomcat container
20-
- name: nodejs
21-
vars:
22-
nodejs_version_number: "latest-v22.x"
23-
proxy_env: "{{ env_vars }}"
21+
# Install nodejs
22+
# See: https://github.com/bcgov/nr-polaris-collection/tree/main/polaris/deploy/roles/nodejs
23+
- role: nodejs
2424

25-
- name: nodejs_app
26-
vars:
27-
proxy_env: "{{ env_vars }}"
25+
# Install nodejs application
26+
# See: https://github.com/bcgov/nr-polaris-collection/tree/main/polaris/deploy/roles/nodejs_app
27+
- role: nodejs_app
28+
29+
tasks:
30+
- ansible.builtin.stat:
31+
path: custom-tasks.yaml
32+
register: playbookcustomtask
33+
delegate_to: localhost
34+
- ansible.builtin.debug:
35+
msg: >
36+
Warning! Review custom-tasks.yaml carefully. Please thoroughly check for potential issues
37+
such as incorrect paths, overwritten files, or unintentional destructive commands. Failing
38+
to validate the script may result in deployment failures, data loss, or service downtime.
39+
when: playbookcustomtask.stat.exists
40+
- ansible.builtin.include_tasks: custom-tasks.yaml
41+
when: playbookcustomtask.stat.exists
42+
# The following is an example of a custom-tasks.yaml for adding custom webapp configuration files
43+
# ---
44+
# - name: configure nonstandard files
45+
# template:
46+
# src: "{{ playbook_dir }}/templates/{{ item.src }}"
47+
# dest: "{{ item.dest }}"
48+
# mode: "0775"
49+
# become: yes
50+
# become_user: "{{ install_user }}"
51+
# with_items:
52+
# - {
53+
# src: "configuration.ts.j2",
54+
# dest: "{{ nodejs_app_service_install_app_home }}/dist/src/config/configuration.js"
55+
# }

playbooks/vars/standard/all.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
# The following properties are required by all services
1+
# This file was generated by the nr-repository-composer pd-nodejs-playbook generator.
2+
# This file is used for standard variables related to all environments.
23
# Ansible connection properties
34
ssh_user: "{{ lookup('ansible.builtin.env', 'PODMAN_CD_USER') }}"
45
ssh_pass: "{{ lookup('ansible.builtin.env', 'PODMAN_CD_PASS') }}"
56
ansible_user: "{{ lookup('ansible.builtin.env', 'PODMAN_CD_USER') }}"
67
ansible_become_password: "{{ lookup('ansible.builtin.env', 'PODMAN_CD_PASS') }}"
78
ansible_ssh_extra_args: "-o StrictHostKeyChecking=no"
89

9-
polaris_apps_project_version: "{{ lookup('ansible.builtin.env', 'PODMAN_PROJECT_VERSION') }}"
10-
polaris_apps_build_number: "{{ lookup('ansible.builtin.env', 'PODMAN_BUILD_NUMBER') }}"
11-
1210
# General properties
1311
polaris_apps_project_name: "NODEJS-SAMPLE"
1412
polaris_apps_service_name: "nodejs-sample"
13+
14+
polaris_apps_project_version: "{{ lookup('ansible.builtin.env', 'PODMAN_PROJECT_VERSION') }}"
15+
polaris_apps_build_number: "{{ lookup('ansible.builtin.env', 'PODMAN_BUILD_NUMBER') }}"
1516
polaris_apps_service_install_name: "{{ polaris_apps_project_version }}-{{ polaris_apps_build_number }}"
1617

1718
# The following properties are custom to each particular service
18-
context:
1919

2020
# By default, the Tomcat port is set dynamically by using the port_manager role
2121
# If you need to set a static port, replace the dynamic port assignment value with your static value

playbooks/vars/standard/dev.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
# Use this file for properties specific to the development (integration, delivery) environment
2-
webade_jdbc_url: "{{ lookup('ansible.builtin.env', 'PODMAN_webade_jdbc_url') }}"
3-
webade_db_user: "{{ lookup('ansible.builtin.env', 'PODMAN_webade_username') }}"
4-
webade_db_pass: "{{ lookup('ansible.builtin.env', 'PODMAN_webade_password') }}"
5-
webade_env: DEV
1+
# This file was generated by the nr-repository-composer pd-nodejs-playbook generator.
2+
# This file is used for standard variables related to the development (integration, delivery) environment.

playbooks/vars/standard/prod.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
# Use this file for properties specific to the production environment
2-
webade_jdbc_url: "{{ lookup('ansible.builtin.env', 'PODMAN_webade_jdbc_url') }}"
3-
webade_db_user: "{{ lookup('ansible.builtin.env', 'PODMAN_webade_username') }}"
4-
webade_db_pass: "{{ lookup('ansible.builtin.env', 'PODMAN_webade_password') }}"
5-
webade_env: PROD
1+
# This file was generated by the nr-repository-composer pd-nodejs-playbook generator.
2+
# This file is used for standard variables related to the production environment.

playbooks/vars/standard/test.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
# Use this file for properties specific to the test environment
2-
webade_jdbc_url: "{{ lookup('ansible.builtin.env', 'PODMAN_webade_jdbc_url') }}"
3-
webade_db_user: "{{ lookup('ansible.builtin.env', 'PODMAN_webade_username') }}"
4-
webade_db_pass: "{{ lookup('ansible.builtin.env', 'PODMAN_webade_password') }}"
5-
webade_env: TEST
1+
# This file was generated by the nr-repository-composer pd-nodejs-playbook generator.
2+
# This file is used for standard variables related to the test environment.

0 commit comments

Comments
 (0)