Skip to content

Commit 3656867

Browse files
authored
Merge pull request #8 from PSNAppz/1.2.0
1.2.0
2 parents 18240c4 + 2b54786 commit 3656867

File tree

93 files changed

+4186
-5476
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+4186
-5476
lines changed

.copier-answers.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/docker-build.yml

Lines changed: 101 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Docker and Push
1+
name: Build Docker Images
22

33
on:
44
push:
@@ -8,45 +8,115 @@ on:
88
- '**'
99
workflow_dispatch:
1010

11+
env:
12+
NAMESPACE: ${{ secrets.docker_hub_organisation || 'openg2p' }}
13+
REGISTRY: docker.io
14+
1115
jobs:
12-
docker-build:
13-
name: Docker Build and Push
16+
build-bene-portal-api:
17+
name: Build Bene Portal API Docker Image
1418
runs-on: ubuntu-latest
1519
env:
16-
NAMESPACE: ${{ secrets.docker_hub_organisation || 'openg2p' }}
17-
SERVICE_NAME: openg2p-spar-mapper-api
20+
SERVICE_NAME: openg2p-spar-bene-portal-api
21+
SERVICE_DIR: openg2p-spar-bene-portal-api
1822
steps:
19-
- uses: actions/checkout@v3
20-
- name: Docker build
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
30+
- name: Extract branch name
31+
shell: bash
2132
run: |
2233
BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')
23-
if [ $? -ne 0 ];then
24-
echo "::error::Failed to Login to dockerhub"
25-
exit 1;
34+
VERSION=$BRANCH_NAME
35+
if [[ $BRANCH_NAME == master || $BRANCH_NAME == main ]]; then
36+
VERSION=latest
2637
fi
38+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
39+
echo "VERSION=$VERSION" >> $GITHUB_ENV
40+
echo "IMAGE_ID=${{ env.NAMESPACE }}/${{ env.SERVICE_NAME }}" >> $GITHUB_ENV
2741
28-
IMAGE_ID=$NAMESPACE/$SERVICE_NAME
42+
- name: Build Docker image
43+
uses: docker/build-push-action@v5
44+
with:
45+
context: .
46+
file: Dockerfile.bene-portal
47+
push: false
48+
tags: ${{ env.IMAGE_ID }}:${{ env.VERSION }}
49+
cache-from: type=gha
50+
cache-to: type=gha,mode=max
2951

30-
# Change all uppercase to lowercase
31-
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
52+
- name: Login to Docker Hub
53+
if: github.event_name == 'push'
54+
uses: docker/login-action@v3
55+
with:
56+
username: ${{ secrets.docker_hub_actor }}
57+
password: ${{ secrets.docker_hub_token }}
58+
59+
- name: Push Docker image
60+
if: github.event_name == 'push'
61+
uses: docker/build-push-action@v5
62+
with:
63+
context: .
64+
file: Dockerfile.bene-portal
65+
push: true
66+
tags: ${{ env.IMAGE_ID }}:${{ env.VERSION }}
67+
cache-from: type=gha
68+
cache-to: type=gha,mode=max
69+
70+
build-spar-mapper-api:
71+
name: Build SPAR Mapper API Docker Image
72+
runs-on: ubuntu-latest
73+
env:
74+
SERVICE_NAME: openg2p-spar-mapper-api
75+
SERVICE_DIR: openg2p-spar-mapper-api
76+
steps:
77+
- uses: actions/checkout@v4
78+
with:
79+
fetch-depth: 0
80+
81+
- name: Set up Docker Buildx
82+
uses: docker/setup-buildx-action@v3
83+
84+
- name: Extract branch name
85+
shell: bash
86+
run: |
87+
BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')
3288
VERSION=$BRANCH_NAME
3389
if [[ $BRANCH_NAME == master || $BRANCH_NAME == main ]]; then
34-
VERSION=develop
90+
VERSION=latest
3591
fi
36-
echo IMAGE_ID=$IMAGE_ID
37-
echo VERSION=$VERSION
38-
echo IMAGE_ID=$IMAGE_ID >> $GITHUB_ENV
39-
echo VERSION=$VERSION >> $GITHUB_ENV
40-
41-
docker build . \
42-
--file Dockerfile \
43-
--tag $IMAGE_ID:$VERSION
44-
if [[ '${{ secrets.docker_hub_token }}' != '' && '${{ secrets.docker_hub_actor }}' != '' ]]; then
45-
export DOCKER_PUSH="true"
46-
echo DOCKER_PUSH=$DOCKER_PUSH >> $GITHUB_ENV
47-
fi
48-
- name: Docker push
49-
if: env.DOCKER_PUSH == 'true'
50-
run: |
51-
echo "${{ secrets.docker_hub_token }}" | docker login -u ${{ secrets.docker_hub_actor }} --password-stdin
52-
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}
92+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
93+
echo "VERSION=$VERSION" >> $GITHUB_ENV
94+
echo "IMAGE_ID=${{ env.NAMESPACE }}/${{ env.SERVICE_NAME }}" >> $GITHUB_ENV
95+
96+
- name: Build Docker image
97+
uses: docker/build-push-action@v5
98+
with:
99+
context: .
100+
file: Dockerfile.mapper
101+
push: false
102+
tags: ${{ env.IMAGE_ID }}:${{ env.VERSION }}
103+
cache-from: type=gha
104+
cache-to: type=gha,mode=max
105+
106+
- name: Login to Docker Hub
107+
if: github.event_name == 'push'
108+
uses: docker/login-action@v3
109+
with:
110+
username: ${{ secrets.docker_hub_actor }}
111+
password: ${{ secrets.docker_hub_token }}
112+
113+
- name: Push Docker image
114+
if: github.event_name == 'push'
115+
uses: docker/build-push-action@v5
116+
with:
117+
context: .
118+
file: Dockerfile.mapper
119+
push: true
120+
tags: ${{ env.IMAGE_ID }}:${{ env.VERSION }}
121+
cache-from: type=gha
122+
cache-to: type=gha,mode=max
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: OpenAPI Generate for Bene Portal
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
tags-ignore:
8+
- '**'
9+
workflow_dispatch:
10+
11+
jobs:
12+
openapi-publish:
13+
name: OpenAPI Generate (Bene Portal)
14+
runs-on: ubuntu-latest
15+
defaults:
16+
run:
17+
working-directory: openg2p-spar-bene-portal-api
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: Get branch name (merge)
21+
run: |
22+
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\\(.*\\),\\1,')" >> $GITHUB_ENV
23+
- name: Setup python for openapi generate
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: "3.10"
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install git+https://github.com/openg2p/openg2p-fastapi-common@v1.1.4\#subdirectory=openg2p-fastapi-auth-models
30+
python -m pip install git+https://github.com/openg2p/openg2p-fastapi-common@v1.1.4\#subdirectory=openg2p-fastapi-auth
31+
python -m pip install git+https://github.com/openg2p/openg2p-fastapi-common@v1.1.4\#subdirectory=openg2p-fastapi-common
32+
- name: Install local models and core lib
33+
run: |
34+
cd ../openg2p-spar-models && pip install -e . --quiet && cd ../openg2p-spar-bene-portal-api
35+
cd ../openg2p-spar-mapper-core && pip install -e . --quiet && cd ../openg2p-spar-bene-portal-api
36+
- name: Install app
37+
run: |
38+
python -m pip install .
39+
- name: Generate openapi json
40+
run: |
41+
mkdir -p src/openg2p_spar_bene_portal_api/api-docs/generated
42+
python3 main.py getOpenAPI src/openg2p_spar_bene_portal_api/api-docs/generated/openapi.json
43+
if ! [ -z "$(git status --porcelain=v1 2>/dev/null -- openg2p-spar-bene-portal-api/src/openg2p_spar_bene_portal_api/api-docs/generated/openapi.json)" ]; then
44+
shopt -s nocasematch
45+
if [[ ${{ github.repository_owner }} == 'OpenG2P' ]]; then
46+
export OPENAPI_CHANGED="true"
47+
echo OPENAPI_CHANGED=$OPENAPI_CHANGED >> $GITHUB_ENV
48+
fi
49+
fi
50+
- name: Commit Changes
51+
uses: EndBug/add-and-commit@v7
52+
if: env.OPENAPI_CHANGED == 'true'
53+
with:
54+
default_author: github_actions
55+
message: "Generated new openapi.json (bene-portal-api) on push to ${{ github.event.inputs.git-ref }}"
56+
add: "openg2p-spar-bene-portal-api/src/openg2p_spar_bene_portal_api/api-docs/generated/openapi.json"

.github/workflows/openapi-push.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
jobs:
77
publish-to-pypi:
88
runs-on: ubuntu-latest
9+
defaults:
10+
run:
11+
working-directory: openg2p-spar-mapper-api
912
steps:
1013
- name: Set up Python
1114
uses: actions/setup-python@v4

0 commit comments

Comments
 (0)