5
5
paths :
6
6
- " opendata.swiss/ui/**" # Only trigger if files in the ui directory change
7
7
- " .github/workflows/docker-ods-ui.yaml" # Trigger also if this workflow file is changed
8
-
9
- pull_request :
10
- paths :
11
- - " opendata.swiss/ui/**" # Only trigger if files in the ui directory change
12
- - " .github/workflows/docker-ods-ui.yaml" # Trigger also if this workflow file is changed
8
+ - " .github/workflows/previews-ods-ui.yaml" # Trigger also if the previews workflow file is changed
13
9
14
10
jobs :
15
11
docker :
@@ -24,46 +20,24 @@ jobs:
24
20
- name : Checkout
25
21
uses : actions/checkout@v5
26
22
27
- - name : Set up kubectl
28
- if : github.event_name == 'pull_request'
29
- uses : azure/setup-kubectl@v4
30
- with :
31
- version : v1.33.0
32
-
33
- - name : Set up Kustomize
34
- if : github.event_name == 'pull_request'
35
- uses : imranismail/setup-kustomize@v2
36
-
37
23
- name : Install Cosign
38
- if : github.event_name != 'pull_request'
39
24
uses : sigstore/cosign-installer@v3.9.2
40
25
41
26
- name : Set up QEMU
42
- if : github.event_name != 'pull_request'
43
27
uses : docker/setup-qemu-action@v3
44
28
45
29
- name : Set up Docker Buildx
46
- if : github.event_name != 'pull_request'
47
30
uses : docker/setup-buildx-action@v3
48
31
49
32
- name : Login to GitHub Container Registry
50
- if : github.event_name != 'pull_request'
51
33
uses : docker/login-action@v3
52
34
with :
53
35
registry : ghcr.io
54
36
username : ${{ github.actor }}
55
37
password : ${{ secrets.GITHUB_TOKEN }}
56
38
57
- - name : Configure some variables
58
- if : github.event_name == 'pull_request'
59
- id : vars
60
- run : |
61
- echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
62
- echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}" >> $GITHUB_OUTPUT
63
-
64
39
- name : Docker meta
65
40
id : docker_meta
66
- if : github.event_name != 'pull_request'
67
41
uses : docker/metadata-action@v5
68
42
with :
69
43
images : |
76
50
77
51
- name : Build and push Docker images
78
52
id : docker_build
79
- if : github.event_name != 'pull_request'
80
53
uses : docker/build-push-action@v6
81
54
with :
82
55
context : ./opendata.swiss/ui
88
61
linux/amd64
89
62
90
63
- name : Sign the images with GitHub OIDC Token
91
- if : github.event_name != 'pull_request'
92
64
env :
93
65
DIGEST : ${{ steps.docker_build.outputs.digest }}
94
66
TAGS : ${{ steps.docker_meta.outputs.tags }}
98
70
images+="${tag}@${DIGEST} "
99
71
done
100
72
cosign sign --yes ${images}
101
-
102
- - name : Configure cluster context
103
- if : github.event_name == 'pull_request'
104
- run : |
105
- kubectl config set-cluster default "--server=${K8S_API_URL}" --insecure-skip-tls-verify=true
106
- kubectl config set-credentials default "--token=${K8S_TOKEN}"
107
- kubectl config set-context default --cluster=default --namespace=piveau-previews --user=default
108
- kubectl config use-context default
109
-
110
- - name : Generate manifests
111
- if : github.event_name == 'pull_request'
112
- working-directory : ./opendata.swiss/ui/k8s
113
- run : |
114
- kustomize edit set nameprefix "${{ steps.vars.outputs.branch }}-"
115
- kustomize edit add patch --patch "$(cat <<EOF
116
- apiVersion: networking.k8s.io/v1
117
- kind: Ingress
118
- metadata:
119
- name: piveau-ui
120
- spec:
121
- tls:
122
- - secretName: ${{ steps.vars.outputs.branch }}-prev-tls
123
- hosts:
124
- - ${{ steps.vars.outputs.branch }}.piveau-ln-preview.zazukoians.org
125
- rules:
126
- - host: ${{ steps.vars.outputs.branch }}.piveau-ln-preview.zazukoians.org
127
- http:
128
- paths:
129
- - path: /
130
- pathType: Prefix
131
- backend:
132
- service:
133
- name: piveau-ui
134
- port:
135
- name: http
136
- EOF
137
- )"
138
- kustomize edit set image "ghcr.io/opendata-swiss/ods-ui=ghcr.io/opendata-swiss/ods-ui:sha-${{ steps.vars.outputs.short_sha }}"
139
- kustomize edit set label "app.kubernetes.io/instance:${{ steps.vars.outputs.branch }}"
140
- kustomize build | tee manifest.yaml
0 commit comments