Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GitHub操作在合并时运行两次_Github_Github Pages_Github Actions - Fatal编程技术网

GitHub操作在合并时运行两次

GitHub操作在合并时运行两次,github,github-pages,github-actions,Github,Github Pages,Github Actions,我有一个构建和部署GitHub操作,在更新GitHub页面存储库时运行。此外,我有一个更新的食谱使用I商店 大多数时候它运行正常,但偶尔我会从手机上更新(使用工作副本)并进行合并,然后每个操作运行两次,所有操作都是由同一次推送触发的。配方更新操作两次都成功 然而,当这种情况发生时,其中一个构建和部署操作失败,类似于“![remote rejected]master->gh pages(无法锁定ref'refs/heads/gh pages”:位于37c581108d857f9d9c8fe5841

我有一个构建和部署GitHub操作,在更新GitHub页面存储库时运行。此外,我有一个更新的食谱使用I商店

大多数时候它运行正常,但偶尔我会从手机上更新(使用工作副本)并进行合并,然后每个操作运行两次,所有操作都是由同一次推送触发的。配方更新操作两次都成功

然而,当这种情况发生时,其中一个构建和部署操作失败,类似于“![remote rejected]master->gh pages(无法锁定ref'refs/heads/gh pages”:位于37c581108d857f9d9c8fe584103d78e4473d280b,但预期为CEAF249CC2F7864F0269E64D372FC40CEB06E0)”

它不会破坏任何东西,但我不确定为什么会发生,我想修复它

构建和部署


on:
  push:
    branches:
      - main
  schedule:
    - cron:  '0 */2 * * *'
  workflow_dispatch:


jobs:

  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Code
        uses: actions/checkout@v2
        with:
          persist-credentials: false

      - name: Setup Python Environment
        uses: actions/setup-python@v2
        with:
          python-version: 3.8
        
      - name: Install Requirements
        run: pip install -r requirements.txt

      - name: Execute Python script
        run: |
          python3 -m papexp
        env:
          EMAIL: ${{ secrets.EMAIL }}
          PASSWORD: ${{ secrets.PASSWORD }}

      - name: setup git config
        run: |
          git config --local user.name ${{ secrets.USERNAME_GITHUB }}
          git config --local user.email ${{ secrets.EMAIL }}
          git pull --ff-only origin main
          git add images/recipes/*
          git add .
          git commit -am "Update recipes" || echo "Nothing to update"
      - name: Push changes
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          branch: ${{ github.ref }}

我不认为这个动作会因为一次推送而运行两次,我也不认为这与你是否从手机更新有关

当您按下main按钮时,您的操作会运行,但它也会每2小时运行一次。因此,当推送触发的操作与计划的操作同时运行时,有时会发生冲突

如果您需要在这两种情况下(已触发和已计划)运行该操作,并且如果偶尔的碰撞不会给您带来问题,那么我只能忍受它。尝试实现某种锁定机制以避免冲突可能比它的价值更大