Vin*_*fer 11 python git github github-actions
在自托管运行器上的拉取请求期间,尝试仅自动应用黑色和 isort 到某些 python 代码上通过 github 操作更改的文件,然后提交到 PR。但会出现一些错误,例如Not a git repository某些步骤。这是我的工作流程文件:
name: Autolint
on:
pull_request:
types: [opened, synchronize]
jobs:
run-linters:
name: Run linters
runs-on: self-hosted
container:
image: edlut/azion:monster-action-base
options: --privileged
steps:
- name: Install git
run: |
apt-get install -y git
git --version
echo "Path is ... $PATH"
PATH=$PATH:$(which git)
echo "Path is ... $PATH"
- uses: actions/checkout@v2
- name: Debug - Check if .git folder exists
run: |
ls -lah
- name: Install Python dependencies
run: pip3 install black isort
- name: Apply Black
env:
BRANCH: ${{ github.head_ref }}
run: |
echo "Branch is ... ${BRANCH}"
git diff --name-only "$GITHUB_BASE_REF..${BRANCH}" | grep .py | xargs black -l 119
- name: Apply isort
env:
BRANCH: ${{ github.head_ref }}
run: |
git diff --name-only "$GITHUB_BASE_REF..${BRANCH}" | xargs isort
- name: Check for modified files
id: git-check
run: echo ::set-output name=modified::$(if git status | grep "nothing to commit"; then echo "false"; else echo "true"; fi)
- name: Push changes
if: steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name 'My Name'
git config --global user.email 'my-name@gmail.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
# git commit -am "style: Apply Black style"
# git push
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我如何实现这一目标吗?
Jho*_*los 19
name: Version Build
on:
push:
branches: [ develop ]
jobs:
build-version:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: git
run: |
# setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default
git --version
git config user.name "GitHub Actions Bot"
git config user.email "<>"
git status
git tag
git describe
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20786 次 |
| 最近记录: |