1
+ name : Build Portal Images
2
+
3
+ on :
4
+ push :
5
+ branches : ['develop']
6
+ workflow_dispatch :
7
+ inputs :
8
+ specific_group :
9
+ description : ' Build specific group (empty for all)'
10
+ required : false
11
+ type : string
12
+
13
+ jobs :
14
+ prepare :
15
+ runs-on : ubuntu-latest
16
+ outputs :
17
+ matrix : ${{ steps.set-matrix.outputs.matrix }}
18
+ steps :
19
+ - uses : actions/checkout@v4
20
+
21
+ - uses : mikefarah/yq@v4
22
+ id : set-matrix
23
+ with :
24
+ cmd : eval -o=json .groups plugin-groups.yaml
25
+
26
+ - if : inputs.specific_group != ''
27
+ uses : mikefarah/yq@master
28
+ id : set-matrix-filtered
29
+ with :
30
+ cmd : |
31
+ eval -o=json ".groups | { \"${{ inputs.specific_group }}\": .\"${{ inputs.specific_group }}\" }" plugin-groups.yaml
32
+
33
+ - name : Set final matrix
34
+ id : set-final-matrix
35
+ run : |
36
+ if [[ -n "${{ inputs.specific_group }}" ]]; then
37
+ echo "matrix=${{ steps.set-matrix-filtered.outputs.result }}" >> $GITHUB_OUTPUT
38
+ else
39
+ echo "matrix=${{ steps.set-matrix.outputs.result }}" >> $GITHUB_OUTPUT
40
+ fi
41
+
42
+ build :
43
+ needs : prepare
44
+ runs-on : ubuntu-latest
45
+ strategy :
46
+ matrix :
47
+ include : ${{ fromJSON(needs.prepare.outputs.matrix) }}
48
+ permissions :
49
+ packages : write
50
+ contents : read
51
+ steps :
52
+ - uses : actions/checkout@v4
53
+
54
+ - uses : actions/setup-go@v4
55
+ with :
56
+ go-version : ' 1.21'
57
+ cache : true
58
+
59
+ # Cache xportal binary install
60
+ - name : Cache xportal
61
+ id : cache-xportal
62
+ uses : actions/cache@v3
63
+ with :
64
+ path : ~/go/bin/xportal
65
+ key : ${{ runner.os }}-xportal-${{ hashFiles('go.mod', 'go.sum') }}
66
+
67
+ # Install xportal if not cached
68
+ - if : steps.cache-xportal.outputs.cache-hit != 'true'
69
+ name : Install xportal
70
+ run : go install go.lumeweb.com/xportal/cmd/xportal@latest
71
+
72
+ # Build portal with plugins and cache dependencies
73
+ - name : Build portal
74
+ run : |
75
+ PLUGINS=$(echo '${{ toJSON(matrix.plugins) }}' | jq -r 'join(" --with ")')
76
+ xportal build --with $PLUGINS
77
+
78
+ - uses : docker/setup-buildx-action@v3
79
+
80
+ - name : Login to GitHub Container Registry
81
+ uses : docker/login-action@v3
82
+ with :
83
+ registry : ghcr.io
84
+ username : ${{ github.actor }}
85
+ password : ${{ secrets.GITHUB_TOKEN }}
86
+
87
+ - name : Build and push Docker image
88
+ uses : docker/build-push-action@v5
89
+ with :
90
+ push : true
91
+ context : .
92
+ tags : |
93
+ ghcr.io/${{ github.repository }}:${{ matrix.group }}
94
+ cache-from : type=gha
95
+ cache-to : type=gha,mode=max
0 commit comments