Skip to content

Commit 90c5836

Browse files
authored
Automatically create deploy commits in wbaas-deploy (#127)
1 parent 17e1371 commit 90c5836

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

.github/workflows/docker.build.yml

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,70 @@ jobs:
5353
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
5454
push: true
5555
tags: ${{ steps.docker_meta.outputs.tags }}
56-
labels: ${{ steps.docker_meta.outputs.labels }}
56+
labels: ${{ steps.docker_meta.outputs.labels }}
57+
-
58+
name: Check out `wmde/wbaas-deploy` repository in staging child directory
59+
if: github.event_name != 'pull_request'
60+
uses: actions/checkout@v3.5.3
61+
with:
62+
repository: wmde/wbaas-deploy
63+
path: ./repos/wbaas-deploy-staging
64+
-
65+
name: Check out `wmde/wbaas-deploy` repository in production child directory
66+
if: github.event_name != 'pull_request'
67+
uses: actions/checkout@v3.5.3
68+
with:
69+
repository: wmde/wbaas-deploy
70+
path: ./repos/wbaas-deploy-production
71+
-
72+
name: Update helmfile values for local, staging and production
73+
if: github.event_name != 'pull_request'
74+
id: update-helmfile-values
75+
run: |
76+
TAG="$(echo ${{ steps.docker_meta.outputs.tags }} | cut -d':' -f2)"
77+
echo "tag=$TAG" >> $GITHUB_OUTPUT
78+
sed -i "/image:/{n;s/tag:.*/tag: $TAG/;}" ./repos/wbaas-deploy-staging/k8s/helmfile/env/local/tool-cradle.values.yaml.gotmpl
79+
sed -i "/image:/{n;s/tag:.*/tag: $TAG/;}" ./repos/wbaas-deploy-staging/k8s/helmfile/env/staging/tool-cradle.values.yaml.gotmpl
80+
sed -i "/image:/{n;s/tag:.*/tag: $TAG/;}" ./repos/wbaas-deploy-production/k8s/helmfile/env/production/tool-cradle.values.yaml.gotmpl
81+
# run the values script for local, prod and staging
82+
-
83+
name: Truncate commit message
84+
if: github.event_name != 'pull_request'
85+
id: truncate-commit-message
86+
run: |
87+
MSG=$(git log -1 --pretty=format:%s)
88+
echo "msg=$MSG" >> $GITHUB_OUTPUT
89+
-
90+
name: Create Staging+Local Pull Request
91+
uses: peter-evans/create-pull-request@v5
92+
if: github.event_name != 'pull_request'
93+
with:
94+
path: ./repos/wbaas-deploy-staging
95+
commit-message: 'Staging+Local: Deploy new Cradle image ${{ steps.docker_meta.outputs.tags }}'
96+
title: 'Staging+Local: Deploy new Cradle image ${{ steps.docker_meta.outputs.tags }}'
97+
branch: deploy-to-staging-${{ steps.update-helmfile-values.outputs.tag }}
98+
committer: wmdebot <github-bots@wikimedia.de>
99+
author: ${{ github.actor }} <github-bots@wikimedia.de>
100+
labels: automated pr
101+
token: ${{ secrets.WBAAS_DEPLOY_TOKEN }}
102+
body: |
103+
This is an automated update for the `tool-cradle` image in staging and local, using `${{ steps.update-helmfile-values.outputs.tag }}`.
104+
105+
**Changes**: [${{ steps.truncate-commit-message.outputs.msg }}](https://github.com/wbstack/cradle/commit/${{ github.sha }})
106+
-
107+
name: Create Production Pull Request
108+
uses: peter-evans/create-pull-request@v5
109+
if: github.event_name != 'pull_request'
110+
with:
111+
path: ./repos/wbaas-deploy-production
112+
commit-message: 'Production: Deploy new Cradle image ${{ steps.docker_meta.outputs.tags }}'
113+
title: 'Production: Deploy new Cradle image ${{ steps.docker_meta.outputs.tags }}'
114+
branch: deploy-to-production-${{ steps.update-helmfile-values.outputs.tag }}
115+
committer: wmdebot <github-bots@wikimedia.de>
116+
author: ${{ github.actor }} <github-bots@wikimedia.de>
117+
labels: automated pr
118+
token: ${{ secrets.WBAAS_DEPLOY_TOKEN }}
119+
body: |
120+
This is an automated update for the `tool-cradle` image in production, using `${{ steps.update-helmfile-values.outputs.tag }}`.
121+
122+
**Changes**: [${{ steps.truncate-commit-message.outputs.msg }}](https://github.com/wbstack/cradle/commit/${{ github.sha }})

0 commit comments

Comments
 (0)