Skip to content

Commit 3125747

Browse files
authored
feat(ci): auto create PR in wbaas-deploy on tagged image (#377)
1 parent d266ef5 commit 3125747

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/docker.build.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,75 @@ jobs:
5555
push: ${{ github.event_name != 'pull_request' }}
5656
tags: ${{ steps.docker_meta.outputs.tags }}
5757
labels: ${{ steps.docker_meta.outputs.labels }}
58+
59+
-
60+
name: Check whether wbaas-deploy should be updated
61+
id: update-check
62+
run: |
63+
if [[ "$GITHUB_REF" =~ ^refs/tags/.+$ ]]; then
64+
echo "This is a tagged release, will try to create an update in wbaas-deploy."
65+
echo "match=true" >> $GITHUB_OUTPUT
66+
fi
67+
-
68+
name: Check out `wmde/wbaas-deploy` repository in staging child directory
69+
if: steps.update-check.outputs.match == 'true'
70+
uses: actions/[email protected]
71+
with:
72+
repository: wmde/wbaas-deploy
73+
path: ./repos/wbaas-deploy-staging
74+
-
75+
name: Check out `wmde/wbaas-deploy` repository in production child directory
76+
if: steps.update-check.outputs.match == 'true'
77+
uses: actions/[email protected]
78+
with:
79+
repository: wmde/wbaas-deploy
80+
path: ./repos/wbaas-deploy-production
81+
-
82+
name: Update values for local, staging and production
83+
if: steps.update-check.outputs.match == 'true'
84+
id: update-values
85+
run: |
86+
TAG="$GITHUB_REF_NAME"
87+
echo "tag=$TAG" >> $GITHUB_OUTPUT
88+
sed -i "/image:/{n;s/tag:.*/tag: $TAG/;}" ./repos/wbaas-deploy-staging/k8s/helmfile/env/local/mediawiki-139.values.yaml.gotmpl
89+
sed -i "/image:/{n;s/tag:.*/tag: $TAG/;}" ./repos/wbaas-deploy-staging/k8s/helmfile/env/staging/mediawiki-139.values.yaml.gotmpl
90+
sed -i "/image:/{n;s/tag:.*/tag: $TAG/;}" ./repos/wbaas-deploy-production/k8s/helmfile/env/production/mediawiki-139.values.yaml.gotmpl
91+
-
92+
name: Truncate commit message
93+
if: steps.update-check.outputs.match == 'true'
94+
id: truncate-commit-message
95+
run: |
96+
MSG=$(echo "${{ github.event.head_commit.message }}" | head -n 1)
97+
echo "msg=$MSG" >> $GITHUB_OUTPUT
98+
-
99+
uses: peter-evans/create-pull-request@v4
100+
if: steps.update-check.outputs.match == 'true'
101+
with:
102+
path: ./repos/wbaas-deploy-staging
103+
commit-message: 'Staging+Local: Deploy new MediaWiki image ${{ steps.update-values.outputs.tag }}'
104+
title: 'Staging+Local: Deploy new MediaWiki image ${{ steps.update-values.outputs.tag }}'
105+
branch: deploy-to-staging-${{ steps.update-values.outputs.tag }}
106+
committer: wmdebot <[email protected]>
107+
author: wmdebot <[email protected]>
108+
labels: automated pr
109+
token: ${{ secrets.WBAAS_DEPLOY_TOKEN }}
110+
body: |
111+
This is an automated update for the `mediawiki` image in staging and local, using `${{ steps.update-values.outputs.tag }}`.
112+
113+
**Changes**: [${{ steps.truncate-commit-message.outputs.msg }}](https://github.com/wbstack/mediawiki/commit/${{ github.sha }})
114+
-
115+
uses: peter-evans/create-pull-request@v4
116+
if: steps.update-check.outputs.match == 'true'
117+
with:
118+
path: ./repos/wbaas-deploy-production
119+
commit-message: 'Production: Deploy new MediaWiki image ${{ steps.update-values.outputs.tag }}'
120+
title: 'Production: Deploy new MediaWiki image ${{ steps.update-values.outputs.tag }}'
121+
branch: deploy-to-production-${{ steps.update-values.outputs.tag }}
122+
committer: wmdebot <[email protected]>
123+
author: wmdebot <[email protected]>
124+
labels: automated pr
125+
token: ${{ secrets.WBAAS_DEPLOY_TOKEN }}
126+
body: |
127+
This is an automated update for the `mediawiki` image in production, using `${{ steps.update-values.outputs.tag }}`.
128+
129+
**Changes**: [${{ steps.truncate-commit-message.outputs.msg }}](https://github.com/wbstack/mediawiki/commit/${{ github.sha }})

0 commit comments

Comments
 (0)