JamesIves / github-pages-deploy-action

🚀 Automatically deploy your project to GitHub Pages using GitHub Actions. This action can be configured to push your production-ready code into any branch you'd like.
https://github.com/marketplace/actions/deploy-to-github-pages
MIT License
4.27k stars 359 forks source link

Not able to remove origin #1117

Closed henri-hulski closed 2 years ago

henri-hulski commented 2 years ago

Describe the bug

Deployment fails with permission issues when trying to remove origin.

Logs

Run JamesIves/github-pages-deploy-action@v4.3.0
  with:
    branch: gh-pages
    folder: docs/build
    token: ***
    clean: true
    force: true
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.9.1[2](https://github.com/stephenmcd/mezzanine/runs/6409254617?check_suite_focus=true#step:9:2)/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/[3](https://github.com/stephenmcd/mezzanine/runs/6409254617?check_suite_focus=true#step:9:3).9.12/x6[4](https://github.com/stephenmcd/mezzanine/runs/6409254617?check_suite_focus=true#step:9:4)/lib
    RELEASE_TAG: v6.0.0

    đź’– Support: https://github.com/sponsors/JamesIves
    đź“Ł Maintained by James Ives: https://jamesiv.es

    🚀 Getting Started Guide: https://github.com/JamesIves/github-pages-deploy-action
    âť“ Discussions / Q&A: https://github.com/JamesIves/github-pages-deploy-action/discussions
    🔧 Report a Bug: https://github.com/JamesIves/github-pages-deploy-action/issues
Checking configuration and starting deployment… 🚦
Deploying using Deploy Token… 🔑
Configuring git…
/usr/bin/git config user.name henri-hulski
/usr/bin/git config user.email henri.hulski@gazeta.pl
/usr/bin/git config core.ignorecase false
/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
/usr/bin/git remote rm origin
error: cannot lock ref 'refs/remotes/origin/cleanup/confirmation-loops': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/cleanup/confirmation-loops.lock': Permission denied
error: could not remove reference refs/remotes/origin/cleanup/confirmation-loops
error: cannot lock ref 'refs/remotes/origin/cleanup/less-flake8-warnings': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/cleanup/less-flake8-warnings.lock': Permission denied
error: could not remove reference refs/remotes/origin/cleanup/less-flake8-warnings
error: cannot lock ref 'refs/remotes/origin/docs/settings_label': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/docs/settings_label.lock': Permission denied
error: could not remove reference refs/remotes/origin/docs/settings_label
error: cannot lock ref 'refs/remotes/origin/dougeven/readme': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/dougeven/readme.lock': Permission denied
error: could not remove reference refs/remotes/origin/dougeven/readme
error: cannot lock ref 'refs/remotes/origin/dougeven/supervisortemplatetweak': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/dougeven/supervisortemplatetweak.lock': Permission denied
error: could not remove reference refs/remotes/origin/dougeven/supervisortemplatetweak
error: cannot lock ref 'refs/remotes/origin/feature/269/fix-unassigned-mimetype-error': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/269/fix-unassigned-mimetype-error.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/269/fix-unassigned-mimetype-error
error: cannot lock ref 'refs/remotes/origin/feature/30331273/backport-django-forms-builder-signals': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/30331273/backport-django-forms-builder-signals.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/30331273/backport-django-forms-builder-signals
error: cannot lock ref 'refs/remotes/origin/feature/313786[5](https://github.com/stephenmcd/mezzanine/runs/6409254617?check_suite_focus=true#step:9:5)9/fix-ignores-show-in-navigation-at-level-1': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/31378[6](https://github.com/stephenmcd/mezzanine/runs/6409254617?check_suite_focus=true#step:9:6)59/fix-ignores-show-in-navigation-at-level-1.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/313[7](https://github.com/stephenmcd/mezzanine/runs/6409254617?check_suite_focus=true#step:9:7)[8](https://github.com/stephenmcd/mezzanine/runs/6409254617?check_suite_focus=true#step:9:8)65[9](https://github.com/stephenmcd/mezzanine/runs/6409254617?check_suite_focus=true#step:9:9)/fix-ignores-show-in-navigation-at-level-1
error: cannot lock ref 'refs/remotes/origin/feature/admin-page-ordering-no-parent-and-parent-cycles': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/admin-page-ordering-no-parent-and-parent-cycles.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/admin-page-ordering-no-parent-and-parent-cycles
error: cannot lock ref 'refs/remotes/origin/feature/admin-thumb-size-settings': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/admin-thumb-size-settings.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/admin-thumb-size-settings
error: cannot lock ref 'refs/remotes/origin/feature/custom-model-labels-in-admin-menu': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/custom-model-labels-in-admin-menu.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/custom-model-labels-in-admin-menu
error: cannot lock ref 'refs/remotes/origin/feature/default-menus-forced-to-unicode-fix': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/default-menus-forced-to-unicode-fix.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/default-menus-forced-to-unicode-fix
error: cannot lock ref 'refs/remotes/origin/feature/double-parent-slug-fix': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/double-parent-slug-fix.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/double-parent-slug-fix
error: cannot lock ref 'refs/remotes/origin/feature/dynamic-inlines-fieldsets-1.7': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/dynamic-inlines-fieldsets-1.7.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/dynamic-inlines-fieldsets-1.7
error: cannot lock ref 'refs/remotes/origin/feature/i18n-url-language-prefix-fix': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/i18n-url-language-prefix-fix.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/i18n-url-language-prefix-fix
error: cannot lock ref 'refs/remotes/origin/feature/jquery-ui-filename-in-templates': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/jquery-ui-filename-in-templates.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/jquery-ui-filename-in-templates
error: cannot lock ref 'refs/remotes/origin/feature/keywords-delete-unused': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/keywords-delete-unused.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/keywords-delete-unused
error: cannot lock ref 'refs/remotes/origin/feature/login-url-view-1.7': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/login-url-view-1.7.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/login-url-view-1.7
error: cannot lock ref 'refs/remotes/origin/feature/menus-field-and-runtime-settings-changes-2': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/menus-field-and-runtime-settings-changes-2.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/menus-field-and-runtime-settings-changes-2
error: cannot lock ref 'refs/remotes/origin/feature/page-menu-context': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/page-menu-context.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/page-menu-context
error: cannot lock ref 'refs/remotes/origin/feature/rating-thanks': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/rating-thanks.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/rating-thanks
error: cannot lock ref 'refs/remotes/origin/feature/split-generate-short-url': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/split-generate-short-url.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/split-generate-short-url
error: cannot lock ref 'refs/remotes/origin/feature/test-optional-apps': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/test-optional-apps.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/test-optional-apps
error: cannot lock ref 'refs/remotes/origin/feature/too-short-password-message-translation-fix': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/too-short-password-message-translation-fix.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/too-short-password-message-translation-fix
error: cannot lock ref 'refs/remotes/origin/feature/translatable-site-permissions': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/translatable-site-permissions.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/translatable-site-permissions
error: cannot lock ref 'refs/remotes/origin/feature/x/add-dropdown-menu-support': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/x/add-dropdown-menu-support.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/x/add-dropdown-menu-support
error: cannot lock ref 'refs/remotes/origin/feature/x/add-sidebar-menu-support': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/feature/x/add-sidebar-menu-support.lock': Permission denied
error: could not remove reference refs/remotes/origin/feature/x/add-sidebar-menu-support
error: cannot lock ref 'refs/remotes/origin/fix/migration-on-delete': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/fix/migration-on-delete.lock': Permission denied
error: could not remove reference refs/remotes/origin/fix/migration-on-delete
error: cannot lock ref 'refs/remotes/origin/fix/sqlite-configuration-without-name': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/fix/sqlite-configuration-without-name.lock': Permission denied
error: could not remove reference refs/remotes/origin/fix/sqlite-configuration-without-name
error: cannot lock ref 'refs/remotes/origin/fix/test-login-required-without-accounts': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/fix/test-login-required-without-accounts.lock': Permission denied
error: could not remove reference refs/remotes/origin/fix/test-login-required-without-accounts
error: cannot lock ref 'refs/remotes/origin/fix/tests-i18n-failures': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/fix/tests-i18n-failures.lock': Permission denied
error: could not remove reference refs/remotes/origin/fix/tests-i18n-failures
error: cannot lock ref 'refs/remotes/origin/git/master': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/git/master.lock': Permission denied
error: could not remove reference refs/remotes/origin/git/master
error: cannot lock ref 'refs/remotes/origin/hkoivuneva/finnish': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/hkoivuneva/finnish.lock': Permission denied
error: could not remove reference refs/remotes/origin/hkoivuneva/finnish
error: cannot lock ref 'refs/remotes/origin/issue/[10](https://github.com/stephenmcd/mezzanine/runs/6409254617?check_suite_focus=true#step:9:10)53': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/issue/1053.lock': Permission denied
error: could not remove reference refs/remotes/origin/issue/1053
error: cannot lock ref 'refs/remotes/origin/maintenance/1.8-get-queryset': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/maintenance/1.8-get-queryset.lock': Permission denied
error: could not remove reference refs/remotes/origin/maintenance/1.8-get-queryset
error: cannot lock ref 'refs/remotes/origin/maintenance/1.8-mandatory-modelform-factory-fields': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/maintenance/1.8-mandatory-modelform-factory-fields.lock': Permission denied
error: could not remove reference refs/remotes/origin/maintenance/1.8-mandatory-modelform-factory-fields
error: cannot lock ref 'refs/remotes/origin/maintenance/unfreeze-future-pep-flakes': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/maintenance/unfreeze-future-pep-flakes.lock': Permission denied
error: could not remove reference refs/remotes/origin/maintenance/unfreeze-future-pep-flakes
error: cannot lock ref 'refs/remotes/origin/pr/[15](https://github.com/stephenmcd/mezzanine/runs/6409254617?check_suite_focus=true#step:9:15)92': Unable to create '/home/runner/work/mezzanine/mezzanine/.git/refs/remotes/origin/pr/1[59](https://github.com/stephenmcd/mezzanine/runs/6409254617?check_suite_focus=true#step:9:59)2.lock': Permission denied
error: could not remove reference refs/remotes/origin/pr/15[92](https://github.com/stephenmcd/mezzanine/runs/6409254617?check_suite_focus=true#step:9:92)
Attempted to remove origin but failed, continuing…
/usr/bin/git remote add origin ***github.com/stephenmcd/mezzanine.git
error: remote origin already exists.
Error: There was an error initializing the repository: The process '/usr/bin/git' failed with exit code 3 ❌
Notice: Deployment failed! ❌

Workflow

  # Create a new semantic release
  # Only runs on the original repo, not forks
  release:
    if: github.repository_owner == 'stephenmcd'
    needs: [test, lint]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
        with:
          python-version: 3.9
      - uses: actions/setup-node@v2
        with:
          node-version: '14' # https://github.com/cycjimmy/semantic-release-action/issues/79#issuecomment-955463633
      - uses: cycjimmy/semantic-release-action@v2
        with:
          semantic_version: 18
          extra_plugins: |
            @semantic-release/exec@5
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          TWINE_USERNAME: __token__
          TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}

  # Build and deploy docs  
  docs:
    if: github.ref == 'refs/heads/stable'
    needs: release
    name: build and deploy docs
    runs-on: ubuntu-latest
    steps:
      - name: Checkout 
        uses: actions/checkout@v3
      - uses: actions/setup-python@v2
        with:
          python-version: 3.9
      - name: Install deps
        run: pip install -e . && pip install sphinx
      - uses: actions-ecosystem/action-get-latest-tag@v1
        id: get-latest-tag
        with:
          semver_only: true
      - name: Get release tag
        run: echo "RELEASE_TAG=${{ steps.get-latest-tag.outputs.tag }}" >> $GITHUB_ENV
      - name: Build docs
        run: sphinx-build -b html docs docs/build && touch docs/build/.nojekyll
      - name: Deploy docs
        uses: JamesIves/github-pages-deploy-action@v4.3.0
        with:
          branch: gh-pages
          folder: docs/build

Additional Comments

The release step succeeded, so there shouldn't be a problem with the GITHUB_TOKEN. I'm using the same setup with stephenmcd/cartridge, where it works fine. Maybe a problem with the initial gh-pages branch, but when I removed it I got the same error.

henri-hulski commented 2 years ago

After deleting the stale branches this issue was solved. Now I get the following error:

with:
    branch: gh-pages
    folder: docs/build
    token: ***
    clean: true
    force: true
  env:
    pythonLocation: /opt/hostedtoolcache/Python/[3](https://github.com/stephenmcd/mezzanine/runs/6443590576?check_suite_focus=true#step:9:3).9.12/x6[4](https://github.com/stephenmcd/mezzanine/runs/6443590576?check_suite_focus=true#step:9:4)
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.12/x64/lib
    RELEASE_TAG: v6.0.0

    đź’– Support: https://github.com/sponsors/JamesIves
    đź“Ł Maintained by James Ives: https://jamesiv.es

    🚀 Getting Started Guide: https://github.com/JamesIves/github-pages-deploy-action
    âť“ Discussions / Q&A: https://github.com/JamesIves/github-pages-deploy-action/discussions
    🔧 Report a Bug: https://github.com/JamesIves/github-pages-deploy-action/issues
Checking configuration and starting deployment… 🚦
Deploying using Deploy Token… 🔑
Configuring git…
/usr/bin/git config --global --add safe.directory /home/runner/work/mezzanine/mezzanine
/usr/bin/git config user.name henri-hulski
/usr/bin/git config user.email henri.hulski@gazeta.pl
/usr/bin/git config core.ignorecase false
/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
/usr/bin/git remote rm origin
/usr/bin/git remote add origin ***github.com/stephenmcd/mezzanine.git
Git configured… 🔧
Starting to commit changes…
/usr/bin/git ls-remote --heads ***github.com/stephenmcd/mezzanine.git refs/heads/gh-pages
39cd036[5](https://github.com/stephenmcd/mezzanine/runs/6443590576?check_suite_focus=true#step:9:5)8b3d98[6](https://github.com/stephenmcd/mezzanine/runs/6443590576?check_suite_focus=true#step:9:6)[7](https://github.com/stephenmcd/mezzanine/runs/6443590576?check_suite_focus=true#step:9:7)a1f42f2095[8](https://github.com/stephenmcd/mezzanine/runs/6443590576?check_suite_focus=true#step:9:8)f22f17cb1d[9](https://github.com/stephenmcd/mezzanine/runs/6443590576?check_suite_focus=true#step:9:9)9c refs/heads/gh-pages
Creating worktree…
/usr/bin/git fetch --no-recurse-submodules --depth=1 origin gh-pages
From https://github.com/stephenmcd/mezzanine
 * branch              gh-pages   -> FETCH_HEAD
 * [new branch]        gh-pages   -> origin/gh-pages
/usr/bin/git worktree add --no-checkout --detach github-pages-deploy-action-temp-deployment-folder
Preparing worktree (detached HEAD 567c96d2)
/usr/bin/git checkout -B gh-pages origin/gh-pages
Previous HEAD position was 567c96d2 chore: update workflow
Switched to a new branch 'gh-pages'
branch 'gh-pages' set up to track 'origin/gh-pages'.
/usr/bin/chmod -R +rw /home/runner/work/mezzanine/mezzanine/docs/build
/usr/bin/rsync -q -av --checksum --progress /home/runner/work/mezzanine/mezzanine/docs/build/. github-pages-deploy-action-temp-deployment-folder --delete --exclude CNAME --exclude .ssh --exclude .git --exclude .github
Checking if there are files to commit…
/usr/bin/git add --all .
error: insufficient permission for adding an object to repository database /home/runner/work/mezzanine/mezzanine/.git/objects
error: .doctrees/multi-tenancy.doctree: failed to insert into database
error: unable to index file '.doctrees/multi-tenancy.doctree'
fatal: adding files failed
Running post deployment cleanup jobs… 🗑️
/usr/bin/git checkout -B github-pages-deploy-action/2rbdh7u29
Switched to a new branch 'github-pages-deploy-action/2rbdh7u29'
M   index.html
/usr/bin/chmod -R +rw github-pages-deploy-action-temp-deployment-folder
/usr/bin/git worktree remove github-pages-deploy-action-temp-deployment-folder --force
Error: The deploy step encountered an error: The process '/usr/bin/git' failed with exit code [12](https://github.com/stephenmcd/mezzanine/runs/6443590576?check_suite_focus=true#step:9:12)8 ❌
Notice: Deployment failed! ❌
henri-hulski commented 2 years ago

Maybe it would help to add .gitignore with *.doctree and doctrees.

JamesIves commented 2 years ago

Sorry for the late response time on this. You could add this to your repos .gitignore file before the deployment job runs and I think and it should have the same effect.