我想根据以前的作业(Format)有条件地执行Github。如果代码需要格式化,我想执行以下作业(create_commit),否则跳过它,什么也不做。
不幸的是,目前第二个作业从未触发,无论第一个作业的输出是什么。
我的行动:
name: Format
on: push
jobs:
format:
name: Code formatting in Black
runs-on: ubuntu-latest
outputs:
trigger_commit: ${{ steps.changes_present.outputs.changes_detected }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install package
run: pip install 'black[d]'
- name: Run black formatter
run: black .
- name: Check diff for changes
id: changes_present
run: |
outputs=$(git diff)
if ! [ -z "$outputs" ]
then
echo '::set-output name=changes_detected::true'
fi
create_commit:
runs-on: ubuntu-latest <- Job never executed
needs: format
if: needs.format.outputs.changes_detected == true
steps:
- name: Commit
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git commit -am "Files updated after formatting"
git pushhttps://stackoverflow.com/questions/73763959
复制相似问题