@@ -3,7 +3,7 @@ name: CI pipeline server filter
3
3
on :
4
4
push :
5
5
branches :
6
- - patched-version
6
+ - PILOT-5250
7
7
paths :
8
8
- ' modules/server-filter/**'
9
9
pull_request :
14
14
15
15
jobs :
16
16
17
- build_and_publish :
18
- uses : PilotDataPlatform/shared-ci-tools/.github/workflows/reusable_build_and_publish_pilot.yml@main
19
- with :
20
- matrix_config : ' ["arranger-server-filter"]'
21
- docker_registry : ' pilotdataplatform.azurecr.io'
22
- service_name : ' arranger-server'
23
- secrets : inherit
24
-
25
- trigger_deployment :
26
- needs : [build_and_publish]
27
- uses : PilotDataPlatform/shared-ci-tools/.github/workflows/reusable_trigger_deployment_pilot.yml@main
28
- with :
29
- service_name : ' arranger-server-filter'
30
- app_version : " ${{needs.build_and_publish.outputs.app_version}}"
31
- secrets : inherit
17
+ extract-branch-name :
18
+ runs-on : ubuntu-20.04
19
+ outputs :
20
+ branch : ${{steps.extract_branch.outputs.branch}}
21
+ steps :
22
+ - name : Extract Branch Name
23
+ id : extract_branch
24
+ shell : bash
25
+ run : echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
26
+ get-version :
27
+ runs-on : ubuntu-20.04
28
+ outputs :
29
+ app_version : ${{steps.get-version.outputs.app_version}}
30
+ steps :
31
+ - name : Checkout code
32
+ uses : actions/checkout@v3
33
+ - name : Get Version
34
+ id : get-version
35
+ shell : bash
36
+ run : |
37
+ BRANCH=${GITHUB_REF#refs/heads/}
38
+ BASE_VERSION=`sed -n 's/^ *"version":.*"\([^"]*\)".*/\1/p' package.json`
39
+ if [ $BRANCH == "patched-version" ]; then
40
+ echo "app_version=$BASE_VERSION-`git rev-parse --short HEAD`" >> $GITHUB_OUTPUT
41
+ else
42
+ echo "app_version=$BASE_VERSION" >> $GITHUB_OUTPUT
43
+ fi
44
+
45
+ build-and-push-docker-image :
46
+ needs : [extract-branch-name, get-version]
47
+ if : ${{ needs.extract-branch-name.outputs.branch == 'patched-version'}}
48
+ name : Build server filter Docker image and push to repositories
49
+ runs-on : ubuntu-20.04
50
+ steps :
51
+ - name : Checkout code
52
+ uses : actions/checkout@v3
53
+ - name : Set up Docker Buildx
54
+ id : buildx
55
+ uses : docker/setup-buildx-action@v2
56
+ - name : Login to Github Packages
57
+ uses : docker/login-action@v2
58
+ with :
59
+ registry : pilotdataplatform.azurecr.io
60
+ username : ${{ secrets.ACR_CLIENT }}
61
+ password : ${{ secrets.ACR_SECRET }}
62
+ - name : Docker metadata
63
+ id : meta
64
+ uses : docker/metadata-action@v4
65
+ with :
66
+ # list of Docker images to use as base name for tags
67
+ images : |
68
+ pilotdataplatform.azurecr.io/arranger/arranger-server
69
+ # generate Docker tags based on the following events/attributes
70
+ sep-tags : ' ,'
71
+ tags : |
72
+ type=raw,prefix=arranger-server-filter-,suffix=,value=${{needs.get-version.outputs.app_version}}
73
+ # - name: Image digest
74
+ # run: echo ${{ steps.meta.outputs.tags }}
75
+ - name : Image digest
76
+ run : echo ${{ steps.meta.outputs.tags }}
77
+ - name : Check if Docker image tags exist
78
+ shell : bash
79
+ run : |
80
+ image_tag=$(echo "${{ steps.meta.outputs.tags }}")
81
+ if docker manifest inspect $image_tag >/dev/null; then
82
+ echo "Docker image with tag already exists. Please update the version."
83
+ exit 1
84
+ else
85
+ echo "Image tags do not exist, proceeding..."
86
+ fi
87
+ - name : Build image and push to GitHub Container Registry
88
+ uses : docker/build-push-action@v4
89
+ with :
90
+ # relative path to the place where source code with Dockerfile is located
91
+ context : .
92
+ # Note: tags has to be all lower-case
93
+ tags : ${{ steps.meta.outputs.tags }}
94
+ # build on feature branches, push only on main branch
95
+ push : ${{ github.event_name != 'pull_request' }}
96
+ # Sets the target stage to build
97
+ target : arranger-server
98
+
99
+ trigger_pilot_dev_deployment :
100
+ needs : [build-and-push-docker-image, get-version]
101
+ runs-on : ubuntu-20.04
102
+ if : github.event_name != 'pull_request'
103
+ steps :
104
+ - name : Checkout helmfile repo
105
+ uses : actions/checkout@v2
106
+ with :
107
+ repository : PilotDataPlatform/pilot-helmfile
108
+ ref : ' main' # always checkout main branch
109
+ ssh-key : ${{ secrets.PILOT_HELMFILE_REPO_DEPLOYMENT_KEY }}
110
+
111
+ - name : Update service version
112
+ run : |
113
+ git config user.name "GitHub Actions"
114
+ git config user.email "[email protected] "
115
+ BASE_FILE='./helmfile.d/values/development/dev/pilot-versions-values.yaml'
116
+
117
+ pattern="arranger_server_filter_service"
118
+
119
+ current_version=$(grep -m 1 $pattern $BASE_FILE)
120
+ echo "current version is $current_version"
121
+
122
+ sed -i "/$pattern/,/service/ s/$current_version/ $pattern: ${{needs.get-version.outputs.app_version}}/" $BASE_FILE
123
+ git add $BASE_FILE
124
+ git commit -m "Deploy arranger-admin-server ${{needs.get-version.outputs.app_version}} [app_name:arranger-admin-server, app_version:${{needs.get-version.outputs.app_version}}]"
125
+ git push origin main
0 commit comments