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

GitHub Actions Failure: Helm Chart Release Process Encounters Non-Fast-Forward Push Error and cr upload Exit Status 1 #180

Open
cubxxw opened this issue Jan 8, 2024 · 3 comments

Comments

@cubxxw
Copy link

cubxxw commented Jan 8, 2024

Hello, I have encountered an error in GitHub actions, and I am currently finding it quite challenging to resolve. I would greatly appreciate your guidance on how to proceed. Thank you for your assistance.

Error:

Pushing to branch "gh-pages"
To https://github.com/openimsdk/helm-charts
 ! [rejected]        HEAD -> gh-pages (non-fast-forward)
error: failed to push some refs to 'https://github.com/openimsdk/helm-charts'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. If you want to integrate the remote changes, use 'git pull'
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Error: exit status 1
Usage:
  cr upload [flags]

Flags:
  -c, --commit string                  Target commit for release
      --generate-release-notes         Whether to automatically generate the name and body for this release. See https://docs.github.com/en/rest/releases/releases
  -b, --git-base-url string            GitHub Base URL (only needed for private GitHub) (default "https://api.github.com/")
  -r, --git-repo string                GitHub repository
  -u, --git-upload-url string          GitHub Upload URL (only needed for private GitHub) (default "https://uploads.github.com/")
  -h, --help                           help for upload
      --make-release-latest            Mark the created GitHub release as 'latest' (default true)
  -o, --owner string                   GitHub username or organization
  -p, --package-path string            Path to directory with chart packages (default ".cr-release-packages")
      --packages-with-index            Host the package files in the GitHub Pages branch
      --pages-branch string            The GitHub pages branch (default "gh-pages")
      --pr                             Create a pull request for the chart package against the GitHub Pages branch (must not be set if --push is set)
      --push                           Push the chart package to the GitHub Pages branch (must not be set if --pr is set)
      --release-name-template string   Go template for computing release names, using chart metadata (default "{{ .Name }}-{{ .Version }}")
      --release-notes-file string      Markdown file with chart release notes. If it is set to empty string, or the file is not found, the chart description will be used instead. The file is read from the chart package
      --remote string                  The Git remote used when creating a local worktree for the GitHub Pages branch (default "origin")
      --skip-existing                  Skip upload if release exists
  -t, --token string                   GitHub Auth Token

Global Flags:
      --config string   Config file (default is $HOME/.cr.yaml)

My actions file:

## Reference: https://github.com/helm/chart-releaser-action
name: Chart Publish
on:
  push:
    branches:
      - main
    # paths:
    #   - "charts/**"

permissions:
  contents: write # to push chart release and create a release (helm/chart-releaser-action)
  packages: write # needed for ghcr access
  id-token: write # needed for keyless signing

jobs:
  publish:
    permissions:
      contents: write  # for helm/chart-releaser-action to push chart release and create a release
      packages: write  # to push OCI chart package to GitHub Registry
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
        with:
          fetch-depth: 0

      - name: Install Helm
        uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
        with:
          version: v3.10.1 # Also update in lint-and-test.yaml


      - name: Configure Git
        run: |
          git config user.name "$GITHUB_ACTOR"
          git config user.email "[email protected]"

      - name: Fetch history
        run: git checkout origin/gh-pages index.yaml

      - name: Run chart-releaser
        uses: helm/chart-releaser-action@a917fd15b20e8b64b94d9158ad54cd6345335584 # v1.6.0
        with:
          charts_dir: charts
          config: "./.github/configs/cr.yaml"
          packages_with_index: true
        env:
          CR_TOKEN: "${{ secrets.BOT_GITHUB_TOKEN }}"
          CR_GENERATE_RELEASE_NOTES: true

      - name: Login to GHCR
        uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Push chart to GHCR
        run: |
          shopt -s nullglob
          for pkg in .cr-release-packages/*.tgz; do
            if [ -z "${pkg:-}" ]; then
              break
            fi
            helm push "${pkg}" oci://ghcr.io/${{ github.repository }}
          done
        env:
          HELM_EXPERIMENTAL_OCI: 1
@cubxxw cubxxw changed the title hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart. If you want to integrate the remote changes, use 'git pull' hint: before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. GitHub Actions Failure: Helm Chart Release Process Encounters Non-Fast-Forward Push Error and cr upload Exit Status 1 Jan 8, 2024
@mr-onion-2
Copy link

mr-onion-2 commented Feb 27, 2024

Hi

We have started to experience this error too. We've been using the action for close to 12 months with no issues, but it has started failing since this last week. I'm still trying to pinpoint the exact scenario but it appears to be when multiple charts are updated in the same PR.

The index.yaml file is updated with the new chart but the chart package fails to get pushed to the branch - resulting in 'broken' Helm chart releases.

Thanks in advance.

Packaging chart 'charts/app-A'...
Successfully packaged chart in /home/runner/work/helm-charts/helm-charts/charts/app-A and saved it to: .cr-release-packages/app-A-0.11.14.tgz
Packaging chart 'charts/app-B'...
Successfully packaged chart in /home/runner/work/helm-charts/helm-charts/charts/app-B and saved it to: .cr-release-packages/app-B-3.1.3.tgz
Releasing charts...
Preparing worktree (detached HEAD 2d59b212)
Updating files:  59% (1848/3103)
...
Updating files: 100% (3103/3103), done.
HEAD is now at 2d59b212 Update index.yaml
[detached HEAD 6cef577f] Publishing chart package for app-B-3.1.3
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 app-B-3.1.3.tgz
Pushing to branch "gh-charts"
To https://github.com/xxx/helm-charts
   2d59b212..6cef577f  HEAD -> gh-charts
Preparing worktree (detached HEAD 2d59b212)
Updating files:  58% (1810/3103)
...
Updating files: 100% (3103/3103), done.
HEAD is now at 2d59b212 Update index.yaml
[detached HEAD 67cfc5b2] Publishing chart package for app-A-0.11.14
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 app-A-0.11.14.tgz
Pushing to branch "gh-charts"
To https://github.com/xxx/helm-charts
 ! [rejected]          HEAD -> gh-charts (non-fast-forward)
error: failed to push some refs to 'https://github.com/xxx/helm-charts'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. If you want to integrate the remote changes, use 'git pull'
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Error: exit status 1
Usage:
  cr upload [flags]

Flags:
  -c, --commit string                  Target commit for release
      --generate-release-notes         Whether to automatically generate the name and body for this release. See https://docs.github.com/en/rest/releases/releases
  -b, --git-base-url string            GitHub Base URL (only needed for private GitHub) (default "https://api.github.com/")
  -r, --git-repo string                GitHub repository
  -u, --git-upload-url string          GitHub Upload URL (only needed for private GitHub) (default "https://uploads.github.com/")
  -h, --help                           help for upload
      --make-release-latest            Mark the created GitHub release as 'latest' (default true)
  -o, --owner string                   GitHub username or organization
  -p, --package-path string            Path to directory with chart packages (default ".cr-release-packages")
      --packages-with-index            Host the package files in the GitHub Pages branch
      --pages-branch string            The GitHub pages branch (default "gh-pages")
      --pr                             Create a pull request for the chart package against the GitHub Pages branch (must not be set if --push is set)
      --push                           Push the chart package to the GitHub Pages branch (must not be set if --pr is set)
      --release-name-template string   Go template for computing release names, using chart metadata (default "{{ .Name }}-{{ .Version }}")
      --release-notes-file string      Markdown file with chart release notes. If it is set to empty string, or the file is not found, the chart description will be used instead. The file is read from the chart package
      --remote string                  The Git remote used when creating a local worktree for the GitHub Pages branch (default "origin")
      --skip-existing                  Skip upload if release exists
  -t, --token string                   GitHub Auth Token

Global Flags:
      --config string   Config file (default is $HOME/.cr.yaml)

Error: Process completed with exit code 1.

@cubxxw
Copy link
Author

cubxxw commented Feb 28, 2024

I also have my doubts about that.

@hyb175
Copy link

hyb175 commented May 8, 2024

Currently having the same problem and it looks like it needs to be solved from the CLI side. There is an open PR helm/chart-releaser#314 addressing this specific issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants