forked from Bahmni/openmrs-module-bahmniapps
-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (108 loc) · 3.94 KB
/
build_publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Build and Publish
on:
push:
branches: [master]
paths-ignore:
- "**.md"
repository_dispatch:
types: ["default-config-trigger"]
jobs:
get-version:
#This job reads the .baseversion file and checks it against tags in the repo so that overlap builds don't occur.
#Also provides version as output for other jobs.
name: Get Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set Version Output
id: get-version
run: |
VERSION=$(cat package/.baseversion)
if [ $(git tag -l "$VERSION") ]; then
echo "Version $VERSION already released. Please update your version in package/.baseversion"
exit 1
else
echo "Setting version $VERSION"
echo ::set-output name=version::$VERSION
fi
docker-build-publish:
name: Docker Build & Publish
runs-on: ubuntu-latest
needs: [get-version]
env:
ARTIFACT_VERSION: ${{ needs.get-version.outputs.version }}-${{github.run_number}}
steps:
- uses: actions/checkout@v2
- name: Use Node.js 10.16.3
uses: actions/setup-node@v1
with:
node-version: 10.16.3
- name: Use Ruby 2.5
uses: actions/setup-ruby@v1
with:
ruby-version: 2.5
- run: npm install -g bower
- run: npm install -g grunt-cli
- run: gem install compass
- run: npm install --global yarn
- name: Package
run: cd ui && yarn cache clean && /bin/bash ./scripts/package.sh
- name: Download default_config.zip
run: sh .github/download_artifact.sh default-config default_config ${{secrets.BAHMNI_PAT}}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Docker Build and push
uses: docker/build-push-action@v2
with:
context: .
file: package/docker/Dockerfile
push: true
tags: bahmni/bahmni-web:${{ env.ARTIFACT_VERSION }},bahmni/bahmni-web:latest
helm-package-publish:
name: Helm Package & Publish
runs-on: ubuntu-latest
needs: [get-version, docker-build-publish]
env:
ARTIFACT_VERSION: ${{ needs.get-version.outputs.version }}-${{github.run_number}}
HELM_CHART_PATH: openmrs-module-bahmniapps/package/helm/
steps:
- name: Checkout
uses: actions/checkout@v2
with:
path: openmrs-module-bahmniapps
- name: Update Version and Image Tag
run: |
yq --inplace '.image.tag = "${{ env.ARTIFACT_VERSION }}"' $HELM_CHART_PATH/values.yaml
yq --inplace '.version = "${{ env.ARTIFACT_VERSION }}"' $HELM_CHART_PATH/Chart.yaml
- name: Helm Lint
run: helm lint $HELM_CHART_PATH
- name: Helm Package
run: helm package $HELM_CHART_PATH
- name: Checkout Charts Repository
uses: actions/checkout@v2
with:
repository: Bahmni/helm-charts
ref: gh-pages
path: helm-charts
persist-credentials: false
- name: Copy Helm Archive
run: cp bahmni-web-${{ env.ARTIFACT_VERSION }}.tgz helm-charts/bahmni-web/
- name: Helm Index
working-directory: helm-charts/
run: helm repo index --merge index.yaml --url https://bahmni.github.io/helm-charts/ .
- name: Commit and Push Chart Repository
working-directory: helm-charts/
run: |
git config user.name ${{ secrets.BAHMNI_USERNAME}}
git config user.email ${{ secrets.BAHMNI_EMAIL}}
git add .
git commit -m "Release of bahmni-web-${{ env.ARTIFACT_VERSION }}"
git push 'https://${{ secrets.BAHMNI_USERNAME}}:${{ secrets.BAHMNI_PAT}}@github.com/bahmni/helm-charts.git' gh-pages