Skip to content

Commit 3277e11

Browse files
committed
ci: split workflows
1 parent ef9ed86 commit 3277e11

File tree

2 files changed

+72
-69
lines changed

2 files changed

+72
-69
lines changed

.github/workflows/docker-ods-ui.yaml

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ on:
55
paths:
66
- "opendata.swiss/ui/**" # Only trigger if files in the ui directory change
77
- ".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
139

1410
jobs:
1511
docker:
@@ -24,46 +20,24 @@ jobs:
2420
- name: Checkout
2521
uses: actions/checkout@v5
2622

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-
3723
- name: Install Cosign
38-
if: github.event_name != 'pull_request'
3924
uses: sigstore/cosign-installer@v3.9.2
4025

4126
- name: Set up QEMU
42-
if: github.event_name != 'pull_request'
4327
uses: docker/setup-qemu-action@v3
4428

4529
- name: Set up Docker Buildx
46-
if: github.event_name != 'pull_request'
4730
uses: docker/setup-buildx-action@v3
4831

4932
- name: Login to GitHub Container Registry
50-
if: github.event_name != 'pull_request'
5133
uses: docker/login-action@v3
5234
with:
5335
registry: ghcr.io
5436
username: ${{ github.actor }}
5537
password: ${{ secrets.GITHUB_TOKEN }}
5638

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-
6439
- name: Docker meta
6540
id: docker_meta
66-
if: github.event_name != 'pull_request'
6741
uses: docker/metadata-action@v5
6842
with:
6943
images: |
@@ -76,7 +50,6 @@ jobs:
7650
7751
- name: Build and push Docker images
7852
id: docker_build
79-
if: github.event_name != 'pull_request'
8053
uses: docker/build-push-action@v6
8154
with:
8255
context: ./opendata.swiss/ui
@@ -88,7 +61,6 @@ jobs:
8861
linux/amd64
8962
9063
- name: Sign the images with GitHub OIDC Token
91-
if: github.event_name != 'pull_request'
9264
env:
9365
DIGEST: ${{ steps.docker_build.outputs.digest }}
9466
TAGS: ${{ steps.docker_meta.outputs.tags }}
@@ -98,43 +70,3 @@ jobs:
9870
images+="${tag}@${DIGEST} "
9971
done
10072
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
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: "[UI] Handle previews on PR"
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "opendata.swiss/ui/**" # Only trigger if files in the ui directory change
7+
- ".github/workflows/previews-ods-ui.yaml" # Trigger also if this workflow file is changed
8+
- ".github/workflows/docker-ods-ui.yaml" # Trigger also if the docker workflow file is changed
9+
10+
jobs:
11+
preview:
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
contents: read
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v5
20+
21+
- name: Set up kubectl
22+
uses: azure/setup-kubectl@v4
23+
with:
24+
version: v1.33.0
25+
26+
- name: Set up Kustomize
27+
uses: imranismail/setup-kustomize@v2
28+
29+
- name: Configure some variables
30+
id: vars
31+
run: |
32+
echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
33+
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}" >> $GITHUB_OUTPUT
34+
35+
- name: Configure cluster context
36+
run: |
37+
kubectl config set-cluster default "--server=${K8S_API_URL}" --insecure-skip-tls-verify=true
38+
kubectl config set-credentials default "--token=${K8S_TOKEN}"
39+
kubectl config set-context default --cluster=default --namespace=piveau-previews --user=default
40+
kubectl config use-context default
41+
42+
- name: Generate manifests
43+
working-directory: ./opendata.swiss/ui/k8s
44+
run: |
45+
kustomize edit set nameprefix "${{ steps.vars.outputs.branch }}-"
46+
kustomize edit add patch --patch "$(cat <<EOF
47+
apiVersion: networking.k8s.io/v1
48+
kind: Ingress
49+
metadata:
50+
name: piveau-ui
51+
spec:
52+
tls:
53+
- secretName: ${{ steps.vars.outputs.branch }}-prev-tls
54+
hosts:
55+
- ${{ steps.vars.outputs.branch }}.piveau-ln-preview.zazukoians.org
56+
rules:
57+
- host: ${{ steps.vars.outputs.branch }}.piveau-ln-preview.zazukoians.org
58+
http:
59+
paths:
60+
- path: /
61+
pathType: Prefix
62+
backend:
63+
service:
64+
name: piveau-ui
65+
port:
66+
name: http
67+
EOF
68+
)"
69+
kustomize edit set image "ghcr.io/opendata-swiss/ods-ui=ghcr.io/opendata-swiss/ods-ui:sha-${{ steps.vars.outputs.short_sha }}"
70+
kustomize edit set label "app.kubernetes.io/instance:${{ steps.vars.outputs.branch }}"
71+
kustomize build | tee manifest.yaml

0 commit comments

Comments
 (0)