Skip to content

Commit

Permalink
build(gha): Flux update fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gracedo committed Sep 26, 2024
1 parent b6effbc commit c9025e7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/flux-update-scheduled-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:

jobs:
flux-schedule-check:
if: github.ref == 'refs/heads/main'
name: Flux Update Schedule Check
runs-on:
- self-hosted
Expand All @@ -22,6 +21,29 @@ jobs:
path: kommander
token: ${{ secrets.MESOSPHERECI_USER_TOKEN }}

- name: Import GPG key (kommander workdir)
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
git_push_gpgsign: true
git_config_global: true
workdir: 'kommander'

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
git_push_gpgsign: true
git_config_global: true

- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.PRIVATE_SSH_KEY }}
Expand All @@ -38,4 +60,5 @@ jobs:
- name: Check for Flux update
env:
GH_TOKEN: ${{ secrets.MESOSPHERECI_USER_TOKEN }}
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
run: devbox run -- "make KOMMANDER_REPO_PATH=${GITHUB_WORKSPACE}/kommander make flux-update"
19 changes: 9 additions & 10 deletions hack/flux/update-flux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readonly CURRENT_FLUX_VERSION
KOMMANDER_REPO_PATH="${REPO_ROOT}/kommander" # Override in CI to path of kommander repository.

function check_remote_branch() {
if [[ -n $(git ls-remote --exit-code --heads git@github.com:mesosphere/"$1".git "$2") ]]; then
if [[ -n $(git ls-remote --exit-code --heads https://github.com/mesosphere/"$1".git "$2") ]]; then
echo "Flux update PR is already up!"
exit 0
fi
Expand Down Expand Up @@ -45,14 +45,12 @@ function update_flux() {
kustomize create --autodetect
popd && popd

# Update flux version in defaultApps whenever flux version is upgraded.
sed -i "s/kommander-flux: \".*\"/kommander-flux: \"$LATEST_FLUX_VERSION\"/g" services/kommander/*/defaults/cm.yaml

git add services

if [[ -z "$(git config user.email 2>/dev/null || true)" ]]; then
git config user.email "[email protected]"
git config user.name "mesosphere-teamcity"
git config user.email "[email protected]"
git config user.name "mesosphere-ci"
git config user.signingKey "${GPG_KEY_ID}"
fi

readonly COMMIT_MSG="feat: Upgrade flux to ${LATEST_FLUX_VERSION}"
Expand All @@ -62,7 +60,7 @@ function update_flux() {
git push --set-upstream origin "${BRANCH_NAME}"

git fetch origin main
KOMMANDER_APPLICATIONS_PR=$(gh pr create --base main --fill --head "${BRANCH_NAME}" -t "${COMMIT_MSG}" -l ready-for-review -l ok-to-test -l slack-notify -l open-kommander-pr -l update-licenses)
KOMMANDER_APPLICATIONS_PR=$(gh pr create --base main --fill --head "${BRANCH_NAME}" -t "${COMMIT_MSG}" -l ready-for-review -l ok-to-test -l slack-notify -l update-licenses)
readonly KOMMANDER_APPLICATIONS_PR
echo "${KOMMANDER_APPLICATIONS_PR} is created"
}
Expand All @@ -80,13 +78,14 @@ function bump_kommander_repo_flux() {
sed -i "s~KOMMANDER_APPLICATIONS_REF ?= main~KOMMANDER_APPLICATIONS_REF ?= ${BRANCH_NAME}~g" Makefile
git add Makefile
if [[ -z "$(git config user.email 2>/dev/null || true)" ]]; then
git config user.email "[email protected]"
git config user.name "mesosphere-teamcity"
git config user.email "[email protected]"
git config user.name "mesosphere-ci"
git config user.signingKey "${GPG_KEY_ID}"
fi
git commit -m "${COMMIT_MSG}"
git push --set-upstream origin "${BRANCH_NAME}"
git fetch origin main
gh pr create --base main --fill --head "${BRANCH_NAME}" -t "${COMMIT_MSG}" -l copy-flux-manifests -l ok-to-test -l ready-for-review -l stacked -b "Depends on ${KOMMANDER_APPLICATIONS_PR}"
gh pr create --base main --fill --head "${BRANCH_NAME}" -t "${COMMIT_MSG}" -l copy-flux-manifests -l test/kuttl -l test/kuttl-multi-cluster -l test/airgapped -l test/license -l test/e2e -l ready-for-review -l stacked -b "Depends on ${KOMMANDER_APPLICATIONS_PR}"
popd
}

Expand Down

0 comments on commit c9025e7

Please sign in to comment.