Skip to content

Latest commit

 

History

History
63 lines (51 loc) · 2.1 KB

README.md

File metadata and controls

63 lines (51 loc) · 2.1 KB

last-artifact-action

inspired by actions/download-artifact#3 (comment)

Get 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: or 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 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:

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 to parses the JSON content:

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 }}"