https://github.com/micalevisk/last-artifact-action
GitHub Action to download and read the last artifact uploaded on some GitHub repository.
https://github.com/micalevisk/last-artifact-action
artifacts-repository github-action github-actions-artifacts hacktoberfest nodejs
Last synced: about 2 months ago
JSON representation
GitHub Action to download and read the last artifact uploaded on some GitHub repository.
- Host: GitHub
- URL: https://github.com/micalevisk/last-artifact-action
- Owner: micalevisk
- License: mit
- Created: 2020-03-08T01:01:42.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-04T14:43:10.000Z (about 1 year ago)
- Last Synced: 2025-02-08T20:47:28.470Z (3 months ago)
- Topics: artifacts-repository, github-action, github-actions-artifacts, hacktoberfest, nodejs
- Language: JavaScript
- Homepage:
- Size: 2.05 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# last-artifact-action
> inspired by https://github.com/actions/download-artifact/issues/3#issuecomment-579289919Get the content from a file of the last uploaded artifact on some GitHub repository.
## Inputs
### `repository`
The target GitHub owner and repository name
default: `${{ github.repository }}`You should set `GITHUB_TOKEN` on either [`with:`](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepswith) or [`env:`](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#env) field (not both at same time) to prevent rate limiting.
If `repository` is another private repo, you must define a [PAT with repo scope](https://github.com/settings/tokens/new?scopes=repo) and put this token on your secrets to be used as `GITHUB_TOKEN` value.## Outputs
### `content`
A serialized JSON where each key is the filename and the value its value as string
PS: maybe this won't work with non-text files; and every directory is ignored.### `loaded`
The string `'true'` if an artifact was found and loaded, `'false'` otherwise.## Usage
Minimal example:
```yml
Name: Foo
on: push
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: micalevisk/last-artifact-action@v2
id: result
- if: steps.result.outputs.loaded == 'true'
run: echo "${{ steps.result.outputs.content }}"
```Example using the action [`gr2m/get-json-paths-action`](https://github.com/gr2m/get-json-paths-action) to parses the JSON `content`:
```yml
Name: Bar
on: push
jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Get 'world.txt' file content from last uploaded artifact
- uses: micalevisk/last-artifact-action@v2
id: result
with:
repository: owner/repo ## using another repo
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- uses: gr2m/[email protected]
id: files
with:
json: "${{ steps.result.outputs.content }}"
world_file: "world.txt"
- if: steps.result.outputs.loaded == 'true'
run: echo "${{ steps.files.outputs.word_file }}"
```