Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate updates of existing helm charts #983

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/update-main-source.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Auto-update charts

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'

jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Configure git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Update main-source branch
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamkpickering 🤔 Which one?

GITHUB_WORKFLOW: ${{ github.workflow }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: |
scripts/pull-ci-scripts
BRANCH="auto-update/$(date '+%s')"
git checkout -b "$BRANCH"
bin/partner-charts-ci auto

# exit if there are no changes
git diff --quiet main-source "$BRANCH" && exit 0

# close all existing PRs from branches starting with "auto-update"
gh pr --repo "$GITHUB_REPOSITORY" list --search 'head:auto-update' --json 'headRefName' --jq '.[] | join("\n")' | \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One possible issue is that you should always make sure that this Ubuntu latest image has JQ installed; otherwise, it will break.
My Ubuntu did not come with it installed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this command requires jq - it's just an option. Looking at the dependencies of the gh package, only git is listed. So they must build jq, or its syntax, into gh somehow?

xargs -n 1 gh pr --repo "$GITHUB_REPOSITORY" close

# push changes
git push --set-upstream origin "$BRANCH"
TITLE="Auto-update charts on main-source"
BODY="This PR was created by the \"$GITHUB_WORKFLOW\" workflow. It auto-updates the helm charts on the main-source branch."
gh pr create --repo "$GITHUB_REPOSITORY" --base main-source --head "$BRANCH" --title "$TITLE" --body "$BODY"
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: Release Partner Charts
name: Update main branch from main-source

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
push:
branches:
- main-source

jobs:
release:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -16,17 +17,14 @@ jobs:
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Update main-source branch
- name: Update main branch with latest from main-source
run: |
scripts/pull-ci-scripts
bin/partner-charts-ci auto
git push origin main-source

- name: Update main branch
run: |
# checkout action only fetches main-source, so we need to fetch main branch also
# checkout action only fetches main-source, so we need to fetch main
git fetch origin main --depth 1
git checkout main
git checkout main-source -- index.yaml assets
git commit -m "Release partner charts"
git push origin main
git rm -r assets index.yaml
git checkout main-source -- assets index.yaml
# exit if there are no changes
git diff-index --quiet HEAD assets index.yaml && exit 0
git commit -m "Update partner charts"
git push origin
Loading