upload-artifact/.github/workflows/test-per-file.yml
initdc 35e561c49c feat: add upload one artifact per file
Signed-off-by: initdc <initd@outlook.com>
2022-10-15 10:25:52 +00:00

98 lines
2.4 KiB
YAML

name: Test Artifact Per File
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
jobs:
build:
name: Build
strategy:
matrix:
runs-on: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.runs-on }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install dependencies
run: npm ci
- name: Compile
run: npm run build
- name: npm test
run: npm test
- name: Lint
run: npm run lint
- name: Format
run: npm run format-check
# Test end-to-end by uploading two artifacts and then downloading them
- name: Create artifact files
run: |
mkdir -p path/to/dir-1
mkdir -p path/to/dir-2
mkdir -p path/to/dir-3
mkdir -p path/from/dir-1
echo > path/to/dir-1/file1.txt "path/to/dir-1/file1.txt"
echo > path/to/dir-2/file1.txt "path/to/dir-2/file1.txt"
echo > path/to/dir-2/file2.txt "path/to/dir-2/file2.txt"
echo > path/to/dir-3/file1.txt "path/to/dir-3/file1.txt"
echo > path/to/dir-3/file2.txt "path/to/dir-3/file2.txt"
echo > path/to/dir-3/file3.txt "path/to/dir-3/file3.txt"
echo > path/from/dir-1/file1.txt "path/from/dir-1/file1.txt"
tar -zvcf path/to/dir-3/all.gz path/to/dir-3/*
# Upload a single file artifact
- name: 'Upload artifact #1'
uses: ./
with:
path: path/to/dir-1/file1.txt
artifact-per-file: true
# Upload using a wildcard pattern, name should default to 'artifact' if not provided
- name: 'Upload artifact #2'
uses: ./
with:
path: path/to/dir-2/*
artifact-per-file: true
artifact-name-rule: ${dir}-${base}
# Upload a directory that contains a file that will be uploaded with GZip
- name: 'Upload artifact #3'
uses: ./
with:
path: path/to/dir-3/*.gz
artifact-per-file: true
artifact-name-rule: ${dir}-${name}${ext}
# Upload a directory that contains a file that will be uploaded with GZip
- name: 'Upload artifact #4'
uses: ./
with:
path: |
path/**/dir*/
!path/to/dir-3/*.gz
artifact-per-file: true
artifact-name-rule: ${{ matrix.runs-on }}-${base}