skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

    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 / click on the link under workflow run and see what the artifact will be there . Thank you very much, Niklas Rosencrantz


  2. I tested your code, and an artifact was created. Did you try to create something like this? enter image description here

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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search