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:
- Complete GitHub Actions construct methods
- Make a short term folder in the container being used
- Duplicate all artifacts of curiosity into that short-term folder
- Use GitHub’s upload-artifact action
- Supply a meaningful title for the artifact down load hyperlink
- Specify the path to the folder made up of your GitHub Motion artifacts
- 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 on: press: branches: [ main ] employment: archive-build-artifacts: runs-on: ubuntu-latest actions: - 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/[email protected] with: 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 assets-for-download.zip.
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
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 assets-for-obtain.zip, 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.