如何在 GitHub Actions 工作流程中进行 apt-get 安装?
How to apt-get install in a GitHub Actions workflow?
在新的 GitHub 操作中,我正在尝试安装一个包以便在后续步骤之一中使用它。
name: CI
on: [push, pull_request]
jobs:
translations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Install xmllint
run: apt-get install libxml2-utils
# ...
然而这失败了
Run apt-get install libxml2-utils
apt-get install libxml2-utils
shell: /bin/bash -e {0}
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
##[error]Process completed with exit code 100.
最好的方法是什么?我需要伸手去拿 Docker 吗?
docs 说:
The Linux and macOS virtual machines both run using passwordless sudo
. When you need to execute commands or install tools that require more privileges than the current user, you can use sudo
without needing to provide a password.
因此只需执行以下操作即可:
- name: Install xmllint
run: sudo apt-get install -y libxml2-utils
在新的 GitHub 操作中,我正在尝试安装一个包以便在后续步骤之一中使用它。
name: CI
on: [push, pull_request]
jobs:
translations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Install xmllint
run: apt-get install libxml2-utils
# ...
然而这失败了
Run apt-get install libxml2-utils
apt-get install libxml2-utils
shell: /bin/bash -e {0}
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
##[error]Process completed with exit code 100.
最好的方法是什么?我需要伸手去拿 Docker 吗?
docs 说:
The Linux and macOS virtual machines both run using passwordless
sudo
. When you need to execute commands or install tools that require more privileges than the current user, you can usesudo
without needing to provide a password.
因此只需执行以下操作即可:
- name: Install xmllint
run: sudo apt-get install -y libxml2-utils