Auto update chart/resources #479
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto update chart/resources | |
env: | |
KYMA_BTP_MANAGER_REPO: ${{ github.repository_owner }}/btp-manager | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
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: Set up go environment | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'go.mod' | |
- 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 | |
- name: Notify slack channel about failure | |
if: ${{ !success() && env.SLACK_BOT_TOKEN != ''}} | |
uses: slackapi/[email protected] | |
with: | |
channel-id: 'kyma-gopher-private-alerts' | |
slack-message: "Auto-update of BTP Manager has failed. Check the details at: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |