-
Notifications
You must be signed in to change notification settings - Fork 1
106 lines (89 loc) · 3.5 KB
/
build-dev.yaml
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
name: Build dev on branch push
on:
push:
branches:
- main
- alpha
concurrency:
group: build-dev-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build-frontend:
runs-on: ubuntu-24.04
env:
IMAGE_NAME: frontend-${{ github.ref_name }}
steps:
- name: Git Checkout
uses: actions/checkout@v3
- name: Set env
run: |
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "REGISTRY_IMAGE=${{ vars.OPENSHIFT_EXTERNAL_REPOSITORY }}/${{ vars.OPENSHIFT_LICENSE_PLATE }}-tools/${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
- name: Install OpenShift CLI tools
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4.14"
- name: Login to OpenShift Container Repository
uses: docker/login-action@v3
with:
registry: ${{vars.OPENSHIFT_EXTERNAL_REPOSITORY}}
username: ${{vars.OPENSHIFT_SA_USERNAME}}
password: ${{secrets.OPENSHIFT_SA_PASSWORD}}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "18"
- name: Legacy npm build
run: |
npm install
npm run build
working-directory: frontend-legacy
- name: Docker build
run: |
FONTAWESOME_PACKAGE_TOKEN=${{ secrets.FONTAWESOME_PACKAGE_TOKEN }} docker build --secret id=FONTAWESOME_PACKAGE_TOKEN -t ${{ env.IMAGE_NAME }} -f frontend/Dockerfile.prod .
docker tag ${{ env.IMAGE_NAME }} ${{ env.REGISTRY_IMAGE }}:latest
docker tag ${{ env.IMAGE_NAME }} ${{ env.REGISTRY_IMAGE }}:${{ env.SHORT_SHA }}
- name: Push Docker image
run: docker push --all-tags ${{ env.REGISTRY_IMAGE }}
build-backend:
runs-on: ubuntu-24.04
env:
IMAGE_NAME: backend-${{ github.ref_name }}
steps:
- name: Git Checkout
uses: actions/checkout@v3
- name: Set env
run: |
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "REGISTRY_IMAGE=${{ vars.OPENSHIFT_EXTERNAL_REPOSITORY }}/${{ vars.OPENSHIFT_LICENSE_PLATE }}-tools/${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
- name: Login to OpenShift Container Repository
uses: docker/login-action@v3
with:
registry: ${{vars.OPENSHIFT_EXTERNAL_REPOSITORY}}
username: ${{vars.OPENSHIFT_SA_USERNAME}}
password: ${{secrets.OPENSHIFT_SA_PASSWORD}}
- name: Docker build
run: |
docker build -t ${{ env.IMAGE_NAME }} -f Dockerfile.prod .
docker tag ${{ env.IMAGE_NAME }} ${{ env.REGISTRY_IMAGE }}:latest
docker tag ${{ env.IMAGE_NAME }} ${{ env.REGISTRY_IMAGE }}:${{ env.SHORT_SHA }}
working-directory: backend
- name: Push Docker image
run: docker push --all-tags ${{ env.REGISTRY_IMAGE }}
deploy:
runs-on: ubuntu-24.04
needs: [build-frontend, build-backend]
steps:
- name: Install OpenShift CLI tools
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4.14"
- name: Login OpenShift
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ vars.OPENSHIFT_SERVER_URL }}
openshift_token: ${{ secrets.OPENSHIFT_SERVICE_TOKEN }}
- name: Trigger rollout
run: |
oc -n ${{ vars.OPENSHIFT_LICENSE_PLATE }}-dev rollout restart deployment ${{ github.ref_name }}-frontend
oc -n ${{ vars.OPENSHIFT_LICENSE_PLATE }}-dev rollout restart deployment ${{ github.ref_name }}-backend