September 21, 2023

Github Business

Business Printing

Swiftly publish GitHub Actions artifacts illustration

When a GitHub Steps workflow efficiently completes a create, it creates artifacts these as zip files, compiled code, Java JAR data files and other assembled factors.

Regrettably, the ephemeral Docker container on which the GitHub Actions artifacts are established disappears once the workflow completes. But it’s not that tricky for a developer to have GitHub archive these artifacts and make them accessible as a downloadable hyperlink.

How? Just use the GitHub upload-artifact action.

Ways to publish GitHub Action artifacts

A developer really should abide by these five methods to publish GitHub Steps artifacts for obtain:

  1. Complete GitHub Actions construct methods
  2. Make a short term folder in the container being used
  3. Duplicate all artifacts of curiosity into that short-term folder
  4. Use GitHub’s upload-artifact action
    1. Supply a meaningful title for the artifact down load hyperlink
    2. Specify the path to the folder made up of your GitHub Motion artifacts
  5. Operate the GitHub Steps workflow and obtain the posted artifacts on the workflow’s construct web site

GitHub Steps artifacts YAML case in point

The least complicated way to display how GitHub’s artifact upload motion works is to insert a phase to a easy workflow that creates a momentary directory. Then, use the touch and echo commands to create a couple uncomplicated files. At the time a developer completes this action, the information will publish as artifacts.

Developers ought to use the adhering to GitHub Steps workflow instance to publish artifacts so they grow to be available for download on the GitHub Steps create summary page:

# Publish GitHub workflow artifacts tutorial illustration
title: Publish GitHub Steps Artifacts Instance

    branches: [ main ]

    runs-on: ubuntu-latest

      - name: Step 1 - Make a non permanent artifact downloads folder
        run: mkdir downloads
      - title: move 2 - Increase artifacts to publish to the temp folder
        run: |
          cd downloads
          echo 'alpha'    > alpha.html
          echo 'bravo'    > bravo.html
          echo 'charlie'  > charlie.html
          cd ..
      - title: Phase 3 - Use the Add Artifact GitHub Action
        utilizes: actions/add-artifact@v2
          title: belongings-for-down load
          route: downloads

GitHub Actions artifacts spelled out

The keys to this overall example are the subsequent three methods:

  • First, generate a folder named downloads
  • Next, insert some files to the downloads folder and
  • Third, use the GitHub add-artifact action to pull all the documents in the downloads folder and package deal them in a zip file named

The newly developed zip file is the a person that then gets to be downloadable on the artifacts page when the GitHub Steps workflow operates.

Posted artifacts in GitHub

If a developer is not common with the echo and output switch, the adhering to command will generate a file on the area filesystem named alpha.html with the textual content ‘alpha’ contained in it:

echo 'alpha' > alpha.html
github action artifact

When you publish a GitHub Motion artifact, it can be downloaded from the build’s workflow summary webpage.

Workflow artifact downloads

When this create operates, the standing web site of the workflow will consist of a website link to down load a file named, which will consist of the a few files named alpha.html, bravo.html and charlie.html. This proves that the script will work and tends to make the GitHub Motion artifacts out there for download.

GitHub Actions Artifact Zip

The zip file downloaded as a GitHub Action artifact contains all of the picked construct data files.