我的GitHub Actions工作流为什么没有生成任何构件?

huangapple go评论64阅读模式
英文:

Why is my GitHub Actions workflow not producing any artifacts?

问题

我的GitHub Actions项目进行得很顺利,但没有输出(构件)。所有操作的实质如下 - 我将Docker文件用作容器,在GitHub Actions中部署带有iproute2实用程序的Debian发行版。在容器中执行/bin/ss -tulpn命令,该命令接收打开端口的列表 - 结果将写入文件。该文件上传到挂载到容器的目录,并用作构建产物(打包为tar或deb格式)。输出:工作流文件,Dockerfile,成功完成的操作过程,构建产物,以其中一种格式。

build.yml

# (以下内容不翻译)

docker.yml

# (以下内容不翻译)

docker文件

# (以下内容不翻译)

我尝试在互联网上寻找解决方案,但很遗憾,我陷入了困境,因为我不知道如何解决这个问题。

英文:

My project in GitHub Actions is going fine, but there is no output (artifact). The essence of all manipulations is as follows - I use the Docker file as a container, I deploy the debian distribution with the iproute2 utility in github actions. The /bin/ss -tulpn command is executed in the container, which receives a list of open ports - the result is written to a file. The file is uploaded to a directory mounted to the container and used as an assembly artifact (packed in tar or deb). Output: workflow file, Dockerfile, successfully completed actions process, artifact, in one of the formats.

build.yml

name: Build and Package

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Build and run Docker container
      run: |
        docker build -t mycontainer .
        docker run -v $(pwd)/output:/output mycontainer
                
    - name: Change permissions
      run: |
        sudo chmod -R 777 output/
                
    - name: Create artifact
      run: |
        cd output
        tar -cvzf result.tar.gz result.txt
        mv result.txt result.deb        
      if: always()

    - name: Upload artifact
      uses: actions/upload-artifact@v2
      with:
        name: result-artifact
        path: output/result.tar.gz

docker.yml

name: Example Workflow

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Build and run Docker container
      run: |
        docker build -t mycontainer .
        docker run -v $(pwd)/output:/output mycontainer        

docker file

FROM debian

RUN apt-get update && apt-get install -y iproute2

RUN mkdir /output

CMD /bin/ss -tulpn > /output/result.txt

I tried to look for a solution on the Internet, but, alas, I came to a stupor, because I do not know how to solve the problem

答案1

得分: 1

总之,代码是有效的,但由于奇怪的 GitHub 界面,很难找到构建物。实际上,它位于以下路径中:Actions / 构建和打包。

英文:

In short, the code was working, but because of the strange github interface, the artifact was difficult to find. In fact, it was located along the following path Actions / Build and package.

答案2

得分: 0

我测试了你的代码,生成了一个工件。你尝试创建类似这样的东西吗? 我的GitHub Actions工作流为什么没有生成任何构件?

这可能是一个误解。如果有帮助的话,仓库位于链接https://github.com/montao/glowing-computing-machine/actions/runs/5407377909。

英文:

I tested your code, and an artifact was created. Did you try to create something like this? 我的GitHub Actions工作流为什么没有生成任何构件?

It's a misunderstanding maybe. The repository is at the link https://github.com/montao/glowing-computing-machine/actions/runs/5407377909 if it helps.

huangapple
  • 本文由 发表于 2023年6月29日 04:45:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76576600.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定