我正在尝试从Github Actions运行脚本,但它一直显示:找不到文件或目录。
这是Github Action:
由于某些原因,
我尝试过执行
我已经参考了以下链接来运行 bash 脚本: https://github.community/t/running-a-bash-script/141584
这是Github Action:
name: Build And Deploy
on:
push:
# branches:
# - master`
jobs:
generate-build-number-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# https://github.com/marketplace/actions/build-number-generator
- name: Generate build number
uses: einaregilsson/build-number@v3
with:
token: ${{secrets.github_token}}
- name: Print new build number
run: echo "Build number is $BUILD_NUMBER"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Print GITHUB_WORKSPACE
run: echo ${GITHUB_WORKSPACE}
- name: Build Docker
run: |
chmod +x "${GITHUB_WORKSPACE}/../docker/build-docker.sh"
${GITHUB_WORKSPACE}/../docker/build-docker.sh
- name: Push Docker
run: |
chmod +x "${GITHUB_WORKSPACE}/../docker/push-docker.sh"
${GITHUB_WORKSPACE}/../docker/push-docker.sh
由于某些原因,
GITHUB_WORKSPACE
的路径很奇怪,这就是为什么我必须在路径中添加 ../
,如 ${GITHUB_WORKSPACE}/../docker/push-docker.sh
。有没有办法列出文件或获取当前工作目录以查看文件实际位置?我尝试过执行
echo ${cwd}
和 echo ${pwd}
,但它们都不输出任何内容。我已经参考了以下链接来运行 bash 脚本: https://github.community/t/running-a-bash-script/141584
$PWD
是Bash变量,它包含当前目录的路径;或者运行pwd
命令。 - tripleeechmod + x
有点笨拙。可以在代码库中设置权限,或者显式运行bash path/to/script
,只需要文件的读权限即可。 - tripleeebash path/to/script
来运行。 - Rajan Shahls
。 - tripleee