从git action容器推送时,git push动作不起作用

时间:2019-12-02 19:13:17

标签: github-actions

我在master分支上有一个动作,它在push / merge上构建一个程序包,将其上传到PyPI,然后签出到develop分支,在develop分支中修改版本,并推送到develop分支的来源。 Develop分支具有一个侦听推送/合并并执行快照发布的操作。 当我推动开发时,develop操作可以完美运行并发布快照,但是当master分支推动时,推操作成功,但操作不会触发。我想念什么? 这两个动作都添加在下面。

name: Build and Upload Package to PyPI | Master Branch

on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Set up Python
        uses: actions/setup-python@v1
        with:
          python-version: '3.5'
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install setuptools wheel twine
          pip install GitPython
          pip install bumpversion
      - name: Strip 'snapshot' from version
        run:  sed -i 's/-snapshot//g' setup.py
      - name: Build and publish
        env:
          TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
          TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
          TWINE_REPOSITORY_URL: https://pypi.domain.com
        run: |
          python setup.py sdist bdist_wheel
          twine upload dist/*
      - name: Bump Verison and Push to develop
        run: |
          git stash
          git config --local user.email "name@email.com"
          git config --local user.name "username"
          git checkout develop
          python bump_version.py
          cat .bumpversion.cfg
          git remote set-url --push origin https://username:$GITHUB_TOKEN@github.com/repo/path
          git push origin develop
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

name: Build and Upload Package to PyPI | Develop Branch

on:
  push:
    branches:
      - develop

jobs:
  bumpTag_build_and_publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Set up Python
        uses: actions/setup-python@v1
        with:
          python-version: '3.5'
      - name: Install dependencies for setup
        run: |
          python -m pip install --upgrade pip
          pip install setuptools wheel twine
      - name: Build and publish
        env:
          TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
          TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
          TWINE_REPOSITORY_URL: https://pypi.domain.co,
        run: |
          python setup.py sdist bdist_wheel
          twine upload dist/*

1 个答案:

答案 0 :(得分:1)

故意{strong>提供不允许触发工作流程。如documention所示:

  

(...),如果操作使用存储库的secrets.GITHUB_TOKEN推送代码,则即使存储库包含配置为在发生推送事件时运行的工作流,新的工作流也不会运行。

如果您需要自动推送使工作流程“可见”,则需要创建Personal Access Token,将其添加到repo secrets,然后使用它代替GITHUB_TOKEN

请注意,如果您使用非股票代币,则GitHub会假设您知道自己在做什么-这意味着要防止可能出现的无限循环。尽管您的情况暂时不是 (develop分支不会推送任何内容),但值得记住的是万一工作流有一天会发生变化。