CLOUDP-314966: Use cloud-qa at mongodbgov for gov tests #133
Workflow file for this run
This file contains hidden or 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: Sync helm-charts | |
on: | |
workflow_call: | |
workflow_dispatch: | |
pull_request: | |
types: | |
- closed | |
jobs: | |
verify-helm-changes: | |
if: github.event.pull_request.merged == true && !startsWith(github.event.pull_request.title, 'dependabot') | |
name: Verify if AKO helm charts need updates | |
runs-on: ubuntu-latest | |
environment: release | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout AKO repo | |
uses: actions/checkout@v4 | |
- name: Install devbox | |
uses: jetify-com/[email protected] | |
with: | |
enable-cache: "true" | |
- name: Generate GitHub App Token | |
id: generate_token | |
uses: actions/create-github-app-token@v2 | |
with: | |
app-id: ${{ secrets.AKO_RELEASER_APP_ID }} | |
private-key: ${{ secrets.AKO_RELEASER_RSA_KEY }} | |
owner: ${{ github.repository_owner }} | |
repositories: | | |
mongodb-atlas-kubernetes | |
helm-charts | |
- name: Checkout Helm charts repo | |
uses: actions/checkout@v4 | |
with: | |
repository: mongodb/helm-charts | |
token: ${{ steps.generate_token.outputs.token }} | |
path: helm-charts-cloned | |
persist-credentials: true | |
- name: Generate AKO bundle | |
env: | |
VERSION: "1.0.0" | |
run: | | |
devbox run -- "make generate bundle" | |
- name: Verify if CRDs were changed | |
id: crd-check | |
env: | |
HELM_CRDS_PATH: "./helm-charts-cloned/charts/atlas-operator-crds/templates" | |
run: | | |
devbox run -- "make helm-upd-crds" | |
- name: Verify if RBAC were changed | |
id: rbac-check | |
env: | |
HELM_RBAC_FILE: "./helm-charts-cloned/charts/atlas-operator/rbac.yaml" | |
run: | | |
devbox run -- "make helm-upd-rbac" | |
- name: Patch original AKO chart dependencies | |
run: | | |
awk '{gsub(/repository: *"file:\/\/..\/..\/helm-charts\/atlas-operator-crds"/, "repository: \"https://mongodb.github.io/helm-charts\"")}1' helm-charts/atlas-operator/Chart.yaml > temp.yaml && mv temp.yaml helm-charts/atlas-operator/Chart.yaml | |
- name: Verify if helm-charts need to be synced | |
run: | | |
for dir in ./helm-charts/*; do | |
dir=$(basename "$dir") | |
if [[ -d "./helm-charts-cloned/charts/$dir" ]]; then | |
echo "Checking for changes in the Chart: $dir" | |
if [[ -n $(diff -r "./helm-charts/$dir" "./helm-charts-cloned/charts/$dir") ]]; then | |
echo "> Changes detected for the Chart: $dir" | |
cp -r "./helm-charts/$dir" "./helm-charts-cloned/charts/" | |
else | |
echo "> No changes detected for the Chart: $dir" | |
fi | |
fi | |
done | |
- name: Create PR for helm-charts repo | |
env: | |
GH_TOKEN: ${{ steps.generate_token.outputs.token }} | |
run: | | |
cd ./helm-charts-cloned | |
if [[ -n $(git status --porcelain) ]]; then | |
jobname=${{ github.run_id }} | |
if [[ -n "${{ github.event.pull_request.title }}" ]]; then | |
jobname=$(echo "${{ github.event.pull_request.title }}" | tr -c '[:alnum:]-_' '_') | |
fi | |
export BRANCH=ako-helm-update-"${jobname}" | |
export COMMIT_MESSAGE="[autogenerated] update AKO helm-charts ${jobname} by @${{ github.event.pull_request.user.login }}" | |
export REPO_NAME=helm-charts | |
echo "Changes detected. Creating PR" | |
export GITHUB_TOKEN="${GH_TOKEN}" | |
git checkout -b "${BRANCH}" | |
git add . | |
../scripts/create-signed-commit.sh | |
gh pr create --base main --head "${BRANCH}" --title "${COMMIT_MESSAGE}" --body "${COMMIT_MESSAGE}" | |
fi | |
echo "Nothing to commit" |