-
Notifications
You must be signed in to change notification settings - Fork 18
56 lines (50 loc) · 1.89 KB
/
auto-update.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Auto update chart/resources
env:
KYMA_BTP_MANAGER_REPO: ${{ github.repository_owner }}/btp-manager
SAP_BTP_SERVICE_OPERATOR_REPO: https://github.com/sap/sap-btp-service-operator
GIT_EMAIL: [email protected]
GIT_NAME: kyma-gopher-bot
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
jobs:
auto-bump-chart:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Compare tags
run: |
latest=$(scripts/update/get-latest-chart-version.sh)
current=$(yq '.version' ./module-chart/chart/Chart.yaml)
if [[ $latest == $current ]]; then
echo "versions are the same: $latest=$current"
echo "CONTINUE_JOB=false" >> $GITHUB_ENV
else
echo "version update from $current to $latest"
echo "CONTINUE_JOB=true" >> $GITHUB_ENV
echo "TAG=${latest}" >> $GITHUB_ENV
echo "BRANCH_NAME=chart-${latest}" >> $GITHUB_ENV
echo "MSG=Update module chart and resources to ${latest}" >> $GITHUB_ENV
fi
- name: Update chart and module resources
if: env.CONTINUE_JOB == 'true'
run: |
scripts/update/make-module-chart.sh $TAG
scripts/update/make-module-resources.sh $TAG
- name: Create PR if anything changed
if: env.CONTINUE_JOB == 'true'
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
prs=$(gh pr list -A $GIT_NAME --state open --json headRefName | jq -r '.[] | .headRefName')
if echo $prs | tr " " '\n' | grep -F -q -x $BRANCH_NAME; then
echo "PR already exists, no need to create a new one"
elif [ -z "$(git status --porcelain)" ]; then
echo "nothing changed, no need to create PR"
else
scripts/update/create_pr.sh
fi