如何在GitHub Actions工作流程中轻松安装? [英] How to apt-get install in a GitHub Actions workflow?

查看:67
本文介绍了如何在GitHub Actions工作流程中轻松安装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在新的GitHub Actions中,我试图安装一个软件包,以便在后续步骤之一中使用它.

In the new GitHub Actions, I am trying to install a package in order to use it in one of the next steps.

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吗?

What's the best way to do this? Do I need to reach for Docker?

推荐答案

Linux和macOS虚拟机均使用无密码的 sudo 运行.当您需要执行命令或安装需要比当前用户更多特权的工具时,可以使用 sudo 而不需要提供密码.

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.

因此只需执行以下操作即可

So simply doing the following should work:

- name: Install xmllint
  run: sudo apt-get install libxml2-utils

这篇关于如何在GitHub Actions工作流程中轻松安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆