尝试在自托管运行器上执行pull请求期间,使用github操作将黑色和isort自动应用于某些python代码上更改的文件,然后提交给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有谁能帮我解决这个问题吗?
发布于 2021-08-19 00:45:33
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 describehttps://stackoverflow.com/questions/62960533
复制相似问题