Skip to content

Commit da8e967

Browse files
ci: add generic make-or-fetch-artifact action
1 parent 8871a9d commit da8e967

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Fetch or make an artifact
2+
description: Fetch an artifact with a given key. If it doesn't exist, run the given command and upload it.
3+
inputs:
4+
name:
5+
description: The artifact name
6+
required: true
7+
make-rule:
8+
description: The GNU make rule which produces the artifact
9+
required: true
10+
target-path:
11+
description: The relative path of the final artifact(s)
12+
required: false
13+
default: 'target/release'
14+
# TODO(SimonThormeyer) not supported yet; will be added in a subsequent PR.
15+
preserve-dirs:
16+
description: Whether to use `tar` to compress/extract the final artifact(s).
17+
Required to be `true` if the dir hierarchy needs to be preserved.
18+
multiple rust targets because keys cannot contain commas.
19+
required: false
20+
default: 'false'
21+
runs:
22+
using: composite
23+
steps:
24+
- name: Attempt to download the artifact
25+
uses: actions/download-artifact@v5
26+
with:
27+
name: ${{ inputs.name }}
28+
path: "${{ inputs.target-path }}"
29+
continue-on-error: true
30+
id: artifact-download
31+
32+
- name: Run make ${{ inputs.make-rule }} if needed
33+
if: ${{ steps.artifact-download.outcome == 'failure' }}
34+
run: make ${{ inputs.make-rule }}
35+
shell: bash
36+
37+
- name: Upload artifact if needed
38+
if: ${{ steps.artifact-download.outcome == 'failure' }} && github.repository == 'wireapp/core-crypto'
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: ${{ inputs.name }}
42+
path: ${{ inputs.target-path }}
43+
retention-days: 1
44+
overwrite: 'true'

0 commit comments

Comments
 (0)