diff --git a/.github/workflows/daily.yaml b/.github/workflows/daily.yaml deleted file mode 100644 index 340f19473b..0000000000 --- a/.github/workflows/daily.yaml +++ /dev/null @@ -1,71 +0,0 @@ -# Authors: Samuel Attwood, Nefi Munoz -name: Partner Charts CI - -on: - workflow_dispatch: -# push: -# branches: -# - main-source - -jobs: - sync: #this job should run first - runs-on: ubuntu-latest - steps: - - name: Checkout main-source branch - uses: actions/checkout@v3 - with: - ref: main-source # branch you want to sync - repository: marcosbc/partner-charts # your forked repository URL - - 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: Fetch upstream changes for main-source branch - run: | - git remote add upstream https://github.com/rancher/partner-charts.git # URL of upstream repository - git fetch upstream main-source - - name: Merge upstream changes into main-source branch - run: | - git checkout main-source - git merge upstream/main-source --allow-unrelated-histories --no-edit - git push origin main-source - - name: Merge upstream changes into main branch - run: | - git fetch upstream main # this fetch is necessary here - git checkout main - git merge upstream/main --allow-unrelated-histories --no-edit - git push origin main - - build: - needs: sync #this job should run after "sync" job - runs-on: ubuntu-latest - steps: - - name: Checkout main-source branch - uses: actions/checkout@v3 - - - name: Setup go - uses: actions/setup-go@v3 - with: - go-version: '>=1.17.0' - - - name: Run CI - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global pull.rebase false # merge (this is the default) - scripts/pull-ci-scripts - bin/partner-charts-ci auto - git pull origin main-source - git push origin main-source - - name: Update main branch - run: | - # checkout action is only going to fetch the current branch, so "git checkout main" would fail if we don’t fetch main first - git fetch origin main --depth 1 - git checkout main - rm -r assets index.yaml - git checkout main-source -- index.yaml assets - - name: Auto commit & push - # Defaults pushing to current branch (main) - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: "Release Partner Charts" diff --git a/.github/workflows/sync-fork.yml b/.github/workflows/sync-fork.yml deleted file mode 100644 index bb34baa355..0000000000 --- a/.github/workflows/sync-fork.yml +++ /dev/null @@ -1,48 +0,0 @@ -#Author: Nefi Munoz -name: Sync Fork - -on: -# schedule: - # Runs every day at midnight UTC -# - cron: '0 0 * * *' - workflow_dispatch: - -jobs: - sync: - runs-on: ubuntu-latest - steps: - - name: Checkout main-source branch - uses: actions/checkout@v3 - with: - ref: main-source # branch you want to sync - repository: marcosbc/partner-charts # your forked repository URL - - 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: Fetch upstream changes for main-source branch - run: | - git remote add upstream https://github.com/rancher/partner-charts.git # URL of upstream repository - git fetch upstream main-source - - name: Merge upstream changes into main-source branch - run: | - git checkout main-source - git merge upstream/main-source --allow-unrelated-histories --no-edit - git push origin main-source - # - name: Checkout main branch - # uses: actions/checkout@v3 - # with: - # ref: main # branch you want to sync - # repository: marcosbc/partner-charts # your forked repository URL - # - name: Fetch upstream changes for main branch - # run: | - # git remote add upstream https://github.com/rancher/partner-charts.git # URL of upstream repository - # git fetch upstream main - - name: Merge upstream changes into main branch - run: | - git fetch upstream main # this fetch is necessary here - git checkout main - git merge upstream/main --allow-unrelated-histories --no-edit - git push origin main - - diff --git a/.github/workflows/update-main-source.yml b/.github/workflows/update-main-source.yml new file mode 100644 index 0000000000..92df6ab978 --- /dev/null +++ b/.github/workflows/update-main-source.yml @@ -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 }} + 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")' | \ + xargs --no-run-if-empty -n 1 gh pr --repo "$GITHUB_REPOSITORY" close + + # push changes + git push --set-upstream origin "$BRANCH" + TITLE="[AUTOMATED] 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" diff --git a/.github/workflows/update-main.yml b/.github/workflows/update-main.yml new file mode 100644 index 0000000000..32f22df569 --- /dev/null +++ b/.github/workflows/update-main.yml @@ -0,0 +1,30 @@ +name: Update main branch from main-source + +on: + workflow_dispatch: + push: + branches: + - main-source + +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 branch with latest from main-source + run: | + # checkout action only fetches main-source, so we need to fetch main + git fetch origin main --depth 1 + git checkout 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