Skip to content

Commit 9dace25

Browse files
authored
Merge pull request #94 from immxmmi/93-refactor-generic-build-pipeline
93 refactor generic build pipeline
2 parents 430d867 + bb4e451 commit 9dace25

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

.github/workflows/build.yaml

+33-15
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@ name: Build Training
22

33
on:
44
pull_request:
5+
workflow_dispatch:
56

67
env:
78
REGISTRY: ghcr.io
89
# github.repository as <account>/<repo>
910
IMAGE_NAME: ${{ github.repository }}
11+
HELM_RELEASE: pr-${{ github.event.pull_request.number }}
12+
HELM_NAME: dagger-techlab-puzzle
13+
NAMESPACE: pitc-cicd-dagger-techlab-test
14+
TRAINING_VERSION: ${{ github.sha }}
15+
PR_ENV_URL: https://dagger-techlab-pr-${{ github.event.pull_request.number }}.ocp.cloudscale.puzzle.ch
1016

1117
jobs:
12-
build:
18+
lint:
1319
runs-on: ubuntu-latest
1420
steps:
1521
-
@@ -25,6 +31,17 @@ jobs:
2531
-
2632
name: Lint Markdown
2733
run: npm ci && npm run mdlint
34+
35+
build_and_push:
36+
runs-on: ubuntu-latest
37+
needs: lint
38+
steps:
39+
-
40+
name: Checkout Repository
41+
uses: actions/checkout@v4
42+
with:
43+
submodules: recursive
44+
fetch-depth: 0
2845
-
2946
name: Set up QEMU
3047
uses: docker/setup-qemu-action@v3
@@ -50,6 +67,11 @@ jobs:
5067
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:pr-${{ github.event.pull_request.number }}
5168
cache-from: type=gha
5269
cache-to: type=gha,mode=max
70+
71+
deploy:
72+
runs-on: ubuntu-latest
73+
needs: build_and_push
74+
steps:
5375
-
5476
name: 'Install Helm'
5577
uses: azure/setup-helm@v4
@@ -69,34 +91,30 @@ jobs:
6991
echo "$KUBE_CONFIG" > $HOME/.kube/config
7092
-
7193
name: Deploy Helm Release
72-
env:
73-
TRAINING_HELM_RELEASE: 'pr-${{ github.event.pull_request.number }}'
74-
TRAINING_NAMESPACE: 'pitc-cicd-dagger-techlab-test'
75-
TRAINING_VERSION: '${{ github.sha }}'
7694
run: |
77-
helm upgrade $TRAINING_HELM_RELEASE acend-training-chart --install --wait \
95+
helm upgrade $HELM_RELEASE acend-training-chart --install --wait \
7896
--kubeconfig $HOME/.kube/config \
79-
--namespace=$TRAINING_NAMESPACE \
97+
--namespace=$NAMESPACE \
8098
--set=app.name=$HELM_RELEASE \
8199
--set=app.version=$TRAINING_VERSION \
82100
--repo=https://acend.github.io/helm-charts/ \
83101
--values=helm-chart/values.yaml \
84102
--atomic
85103
-
86104
name: Redeploy Deployments
87-
env:
88-
TRAINING_HELM_RELEASE: 'pr-${{ github.event.pull_request.number }}'
89-
TRAINING_HELM_NAME: 'dagger-techlab-puzzle'
90-
TRAINING_NAMESPACE: 'pitc-cicd-dagger-techlab-test'
91105
run: |
92-
kubectl rollout restart deployment/${TRAINING_HELM_RELEASE}-${TRAINING_HELM_NAME} \
106+
kubectl rollout restart deployment/${HELM_RELEASE}-${HELM_NAME} \
93107
--kubeconfig $HOME/.kube/config \
94-
--namespace $TRAINING_NAMESPACE
108+
--namespace $NAMESPACE
109+
110+
comment:
111+
runs-on: ubuntu-latest
112+
needs: deploy
113+
steps:
95114
-
96115
name: Comment PR Environments in PR
97116
uses: marocchino/sticky-pull-request-comment@v2
98117
with:
99118
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100119
message: |
101-
PR Environments:
102-
* puzzle version <https://dagger-techlab-pr-${{ github.event.pull_request.number }}.ocp.cloudscale.puzzle.ch>
120+
🚀 PR Environment: [Open Deployment](${{ env.PR_ENV_URL }})

0 commit comments

Comments
 (0)