-
Notifications
You must be signed in to change notification settings - Fork 4
90 lines (87 loc) · 2.95 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
name: 🏗️ Build and Publish
on:
push:
branches:
- Bahmni-IPD-Without-Locale
paths-ignore:
- "**.md"
workflow_run:
workflows: [Pull Translations from Transifex]
types: [completed]
branches:
- main
workflow_dispatch:
jobs:
Trivy:
name: 🕵️♂️ Trivy Scan
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout code
uses: actions/checkout@v3
- name: 🕵️♂️ Trivy Scan
run: |
wget -q https://raw.githubusercontent.com/Bahmni/bahmni-infra-utils/main/trivy_scan.sh && chmod +x trivy_scan.sh
./trivy_scan.sh
rm trivy_scan.sh
build-publish-docker:
name: 🏗️ Build & Publish Docker Image
runs-on: ubuntu-latest
needs: Trivy
steps:
- uses: actions/checkout@v2
- name: 📥 Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: 📥 Install dependencies
run: yarn install
- name: 🏗️ Build
run: yarn build
- name: Test
run: yarn test:ci
- name: 🖥️ Set up QEMU
uses: docker/setup-qemu-action@v2
- name: 🖥️ Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: 🔐 Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: 🐳 Docker Build and push
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
file: package/docker/Dockerfile
push: true
tags: |
bahmni/microfrontend-ipd:ipd-without-locale-${{ github.run_number }}
bahmni/microfrontend-ipd:ipd-without-locale
- name: Push Translations to Transifex
run: |
curl -o transifex.sh https://raw.githubusercontent.com/Bahmni/bahmni-infra-utils/main/transifex.sh
chmod +x transifex.sh
./transifex.sh push
rm transifex.sh
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
trigger-workflow:
name: 🔁 Trigger workflow to deploy to Docker env
needs:
- build-publish-docker
- Trivy
runs-on: ubuntu-latest
env:
EVENT_TYPE: bahmni-ipd-microfrontend-event
steps:
- name: 🔧 Create repository_dispatch
run: |
trigger_result=$(curl -s -o trigger_response.txt -w "%{http_code}" -X POST -H "Accept: application/vnd.github.v3+json" -H 'authorization: Bearer ${{ secrets.IPD_PAT }}' https://api.github.com/repos/${{ secrets.IPD_ORG_NAME }}/${{ secrets.IPD_REPOSITORY_NAME }}/dispatches -d '{"event_type":"'"${EVENT_TYPE}"'"}')
if [ $trigger_result == 204 ];then
echo "✅ Trigger to $ORG_NAME/$REPOSITORY_NAME Success"
else
echo "❌ Trigger to $ORG_NAME/$REPOSITORY_NAME Failed"
cat trigger_response.txt
exit 1
fi