github.com/nektos/act@v0.2.63-0.20240520024548-8acde99bfa9c/pkg/artifacts/testdata/upload-and-download/artifacts.yml (about)

     1  
     2  name: "Test that artifact uploads and downloads succeed"
     3  on: push
     4  
     5  jobs:
     6    test-artifacts:
     7      runs-on: ubuntu-latest
     8      steps:
     9        - run: mkdir -p path/to/artifact
    10        - run: echo hello > path/to/artifact/world.txt
    11        - uses: actions/upload-artifact@v2
    12          with:
    13            name: my-artifact
    14            path: path/to/artifact/world.txt
    15  
    16        - run: rm -rf path
    17  
    18        - uses: actions/download-artifact@v2
    19          with:
    20            name: my-artifact
    21        - name: Display structure of downloaded files
    22          run: ls -la
    23  
    24        # Test end-to-end by uploading two artifacts and then downloading them
    25        - name: Create artifact files
    26          run: |
    27            mkdir -p path/to/dir-1
    28            mkdir -p path/to/dir-2
    29            mkdir -p path/to/dir-3
    30            mkdir -p path/to/dir-5
    31            mkdir -p path/to/dir-6
    32            mkdir -p path/to/dir-7
    33            echo "Lorem ipsum dolor sit amet" > path/to/dir-1/file1.txt
    34            echo "Hello world from file #2" > path/to/dir-2/file2.txt
    35            echo "This is a going to be a test for a large enough file that should get compressed with GZip. The @actions/artifact package uses GZip to upload files. This text should have a compression ratio greater than 100% so it should get uploaded using GZip" > path/to/dir-3/gzip.txt
    36            dd if=/dev/random of=path/to/dir-5/file5.rnd bs=1024 count=1024
    37            dd if=/dev/random of=path/to/dir-6/file6.rnd bs=1024 count=$((10*1024))
    38            dd if=/dev/random of=path/to/dir-7/file7.rnd bs=1024 count=$((10*1024))
    39  
    40        # Upload a single file artifact
    41        - name: 'Upload artifact #1'
    42          uses: actions/upload-artifact@v2
    43          with:
    44            name: 'Artifact-A'
    45            path: path/to/dir-1/file1.txt
    46        
    47        # Upload using a wildcard pattern, name should default to 'artifact' if not provided
    48        - name: 'Upload artifact #2'
    49          uses: actions/upload-artifact@v2
    50          with:
    51            path: path/**/dir*/
    52        
    53        # Upload a directory that contains a file that will be uploaded with GZip
    54        - name: 'Upload artifact #3'
    55          uses: actions/upload-artifact@v2
    56          with:
    57            name: 'GZip-Artifact'
    58            path: path/to/dir-3/
    59        
    60        # Upload a directory that contains a file that will be uploaded with GZip
    61        - name: 'Upload artifact #4'
    62          uses: actions/upload-artifact@v2
    63          with:
    64            name: 'Multi-Path-Artifact'
    65            path: |
    66              path/to/dir-1/*
    67              path/to/dir-[23]/*
    68              !path/to/dir-3/*.txt
    69        
    70        # Upload a mid-size file artifact
    71        - name: 'Upload artifact #5'
    72          uses: actions/upload-artifact@v2
    73          with:
    74            name: 'Mid-Size-Artifact'
    75            path: path/to/dir-5/file5.rnd
    76        
    77        # Upload a big file artifact
    78        - name: 'Upload artifact #6'
    79          uses: actions/upload-artifact@v2
    80          with:
    81            name: 'Big-Artifact'
    82            path: path/to/dir-6/file6.rnd
    83  
    84        # Upload a big file artifact twice
    85        - name: 'Upload artifact #7 (First)'
    86          uses: actions/upload-artifact@v2
    87          with:
    88            name: 'Big-Uploaded-Twice'
    89            path: path/to/dir-7/file7.rnd
    90  
    91        # Upload a big file artifact twice
    92        - name: 'Upload artifact #7 (Second)'
    93          uses: actions/upload-artifact@v2
    94          with:
    95            name: 'Big-Uploaded-Twice'
    96            path: path/to/dir-7/file7.rnd
    97  
    98        # Verify artifacts. Switch to download-artifact@v2 once it's out of preview
    99        
   100        # Download Artifact #1 and verify the correctness of the content
   101        - name: 'Download artifact #1'
   102          uses: actions/download-artifact@v2
   103          with:
   104            name: 'Artifact-A'
   105            path: some/new/path
   106        
   107        - name: 'Verify Artifact #1'
   108          run: |
   109            file="some/new/path/file1.txt"
   110            if [ ! -f $file ] ; then
   111              echo "Expected file does not exist"
   112              exit 1
   113            fi
   114            if [ "$(cat $file)" != "Lorem ipsum dolor sit amet" ] ; then
   115              echo "File contents of downloaded artifact are incorrect"
   116              exit 1
   117            fi
   118        
   119        # Download Artifact #2 and verify the correctness of the content
   120        - name: 'Download artifact #2'
   121          uses: actions/download-artifact@v2
   122          with:
   123            name: 'artifact'
   124            path: some/other/path
   125        
   126        - name: 'Verify Artifact #2'
   127          run: |
   128            file1="some/other/path/to/dir-1/file1.txt"
   129            file2="some/other/path/to/dir-2/file2.txt"
   130            if [ ! -f $file1 -o ! -f $file2 ] ; then
   131              echo "Expected files do not exist"
   132              exit 1
   133            fi
   134            if [ "$(cat $file1)" != "Lorem ipsum dolor sit amet" -o "$(cat $file2)" != "Hello world from file #2" ] ; then
   135              echo "File contents of downloaded artifacts are incorrect"
   136              exit 1
   137            fi
   138        
   139        # Download Artifact #3 and verify the correctness of the content
   140        - name: 'Download artifact #3'
   141          uses: actions/download-artifact@v2
   142          with:
   143            name: 'GZip-Artifact'
   144            path: gzip/artifact/path
   145        
   146        # Because a directory was used as input during the upload the parent directories, path/to/dir-3/, should not be included in the uploaded artifact
   147        - name: 'Verify Artifact #3'
   148          run: |
   149            gzipFile="gzip/artifact/path/gzip.txt"
   150            if [ ! -f $gzipFile ] ; then
   151              echo "Expected file do not exist"
   152              exit 1
   153            fi
   154            if [ "$(cat $gzipFile)" != "This is a going to be a test for a large enough file that should get compressed with GZip. The @actions/artifact package uses GZip to upload files. This text should have a compression ratio greater than 100% so it should get uploaded using GZip" ] ; then
   155              echo "File contents of downloaded artifact is incorrect"
   156              exit 1
   157            fi
   158        
   159        - name: 'Download artifact #4'
   160          uses: actions/download-artifact@v2
   161          with:
   162            name: 'Multi-Path-Artifact'
   163            path: multi/artifact
   164        
   165        - name: 'Verify Artifact #4'
   166          run: |
   167            file1="multi/artifact/dir-1/file1.txt"
   168            file2="multi/artifact/dir-2/file2.txt"
   169            if [ ! -f $file1 -o ! -f $file2 ] ; then
   170              echo "Expected files do not exist"
   171              exit 1
   172            fi
   173            if [ "$(cat $file1)" != "Lorem ipsum dolor sit amet" -o "$(cat $file2)" != "Hello world from file #2" ] ; then
   174              echo "File contents of downloaded artifacts are incorrect"
   175              exit 1
   176            fi
   177        
   178        - name: 'Download artifact #5'
   179          uses: actions/download-artifact@v2
   180          with:
   181            name: 'Mid-Size-Artifact'
   182            path: mid-size/artifact/path
   183        
   184        - name: 'Verify Artifact #5'
   185          run: |
   186            file="mid-size/artifact/path/file5.rnd"
   187            if [ ! -f $file ] ; then
   188              echo "Expected file does not exist"
   189              exit 1
   190            fi
   191            if ! diff $file path/to/dir-5/file5.rnd ; then
   192              echo "File contents of downloaded artifact are incorrect"
   193              exit 1
   194            fi
   195        
   196        - name: 'Download artifact #6'
   197          uses: actions/download-artifact@v2
   198          with:
   199            name: 'Big-Artifact'
   200            path: big/artifact/path
   201        
   202        - name: 'Verify Artifact #6'
   203          run: |
   204            file="big/artifact/path/file6.rnd"
   205            if [ ! -f $file ] ; then
   206              echo "Expected file does not exist"
   207              exit 1
   208            fi
   209            if ! diff $file path/to/dir-6/file6.rnd ; then
   210              echo "File contents of downloaded artifact are incorrect"
   211              exit 1
   212            fi
   213  
   214        - name: 'Download artifact #7'
   215          uses: actions/download-artifact@v2
   216          with:
   217            name: 'Big-Uploaded-Twice'
   218            path: big-uploaded-twice/artifact/path
   219  
   220        - name: 'Verify Artifact #7'
   221          run: |
   222            file="big-uploaded-twice/artifact/path/file7.rnd"
   223            if [ ! -f $file ] ; then
   224              echo "Expected file does not exist"
   225              exit 1
   226            fi
   227            if ! diff $file path/to/dir-7/file7.rnd ; then
   228              echo "File contents of downloaded artifact are incorrect"
   229              exit 1
   230            fi