forked from aws-powertools/powertools-lambda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
83 lines (72 loc) · 2.52 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Upload artifact
description: Wrapper around GitHub's official action, with additional archiving before upload
# PROCESS
#
# 1. Creates tarball excluding .git and *.pyc files
# 2. Uploads tarball using actions/upload-artifact action, fail CI job if no file is found
# 3. Remove archive after uploading it.
# NOTES
#
# Upload-artifact and download-artifact takes ~2m40s to upload 8MB
# so this is custom action cuts down the entire operation to 1s
# by uploading/extracting a tarball while relying on the official upload-artifact/download-artifact actions
#
# USAGE
#
# NOTE: Meant to be used with ./.github/actions/download-artifact
#
# - name: Upload sealed source code
# uses: ./.github/actions/upload-artifact
# with:
# name: ${{ steps.integrity.outputs.INTEGRITY_HASH }}
# path: .
# https://github.com/actions/upload-artifact/blob/main/action.yml
inputs:
name:
description: Artifact name
required: true
path:
description: >
A file, directory or wildcard pattern that describes what to upload.
You can pass multiple paths separated by space (e.g., dir1 dir2 file.txt).
Paths and wildcard patterns must be tar command compatible.
required: true
retention-days:
description: >
Artifact retention in days. By default 1 day, max of 90 days, and 0 honours default repo retention.
You can change max days in the repository settings.
required: false
default: "1"
if-no-files-found:
description: >
Action to perform if no files are found: warn, error, ignore. By default, it fails fast with 'error'.
Options:
warn: Output a warning but do not fail the action
error: Fail the action with an error message
ignore: Do not output any warnings or errors, the action does not fail
required: false
default: error
runs:
using: composite
steps:
- name: Archive artifacts
run: |
tar --exclude-vcs \
--exclude "*.pyc" \
-cvf "${ARCHIVE}" "${PATH_TO_ARCHIVE}"
env:
ARCHIVE: ${{ inputs.name }}.tar
PATH_TO_ARCHIVE: ${{ inputs.path }}
shell: bash
- name: Upload artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
if-no-files-found: ${{ inputs.if-no-files-found }}
name: ${{ inputs.name }}
path: ${{ inputs.name }}.tar
retention-days: ${{ inputs.retention-days }}
- name: Remove archive
run: rm -f "${ARCHIVE}"
env:
ARCHIVE: ${{ inputs.name }}.tar
shell: bash