mirror of
https://github.com/actions/upload-artifact.git
synced 2025-04-18 14:34:44 +02:00
feat(test.yml): add AWS credentials configuration for GitHub Actions
feat(test.yml): add KMS key ID to artifact upload and download steps for enhanced security refactor(test.yml): replace PowerShell scripts with bash for file existence checks for better cross-platform compatibility
This commit is contained in:
parent
ee74028ec2
commit
3dc955d747
1 changed files with 40 additions and 37 deletions
77
.github/workflows/test.yml
vendored
77
.github/workflows/test.yml
vendored
|
@ -24,6 +24,12 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
- name: Configure AWS Credentials
|
||||||
|
uses: aws-actions/configure-aws-credentials@v4
|
||||||
|
with:
|
||||||
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
aws-region: us-east-1
|
||||||
|
|
||||||
- name: Setup Node 16
|
- name: Setup Node 16
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
|
@ -62,12 +68,14 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: 'Artifact-A'
|
name: 'Artifact-A'
|
||||||
path: path/to/dir-1/file1.txt
|
path: path/to/dir-1/file1.txt
|
||||||
|
kms-key-id: ${{ secrets.KMS_KEY_ID }}
|
||||||
|
|
||||||
# Upload using a wildcard pattern, name should default to 'artifact' if not provided
|
# Upload using a wildcard pattern, name should default to 'artifact' if not provided
|
||||||
- name: 'Upload artifact #2'
|
- name: 'Upload artifact #2'
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
path: path/**/dir*/
|
path: path/**/dir*/
|
||||||
|
kms-key-id: ${{ secrets.KMS_KEY_ID }}
|
||||||
|
|
||||||
# Upload a directory that contains a file that will be uploaded with GZip
|
# Upload a directory that contains a file that will be uploaded with GZip
|
||||||
- name: 'Upload artifact #3'
|
- name: 'Upload artifact #3'
|
||||||
|
@ -75,6 +83,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: 'GZip-Artifact'
|
name: 'GZip-Artifact'
|
||||||
path: path/to/dir-3/
|
path: path/to/dir-3/
|
||||||
|
kms-key-id: ${{ secrets.KMS_KEY_ID }}
|
||||||
|
|
||||||
# Upload a directory that contains a file that will be uploaded with GZip
|
# Upload a directory that contains a file that will be uploaded with GZip
|
||||||
- name: 'Upload artifact #4'
|
- name: 'Upload artifact #4'
|
||||||
|
@ -85,26 +94,26 @@ jobs:
|
||||||
path/to/dir-1/*
|
path/to/dir-1/*
|
||||||
path/to/dir-[23]/*
|
path/to/dir-[23]/*
|
||||||
!path/to/dir-3/*.txt
|
!path/to/dir-3/*.txt
|
||||||
|
kms-key-id: ${{ secrets.KMS_KEY_ID }}
|
||||||
|
|
||||||
# Download Artifact #1 and verify the correctness of the content
|
# Download Artifact #1 and verify the correctness of the content
|
||||||
- name: 'Download artifact #1'
|
- name: 'Download artifact #1'
|
||||||
uses: actions/download-artifact@v3
|
uses: ./
|
||||||
with:
|
with:
|
||||||
name: 'Artifact-A'
|
name: 'Artifact-A'
|
||||||
path: some/new/path
|
path: some/new/path
|
||||||
|
kms-key-id: ${{ secrets.KMS_KEY_ID }}
|
||||||
|
|
||||||
- name: 'Verify Artifact #1'
|
- name: 'Verify Artifact #1'
|
||||||
run: |
|
run: |
|
||||||
$file = "some/new/path/file1.txt"
|
$file = "some/new/path/file1.txt"
|
||||||
if(!(Test-Path -path $file))
|
if test -f "$file"; then
|
||||||
{
|
echo "$file exists."
|
||||||
Write-Error "Expected file does not exist"
|
else
|
||||||
}
|
echo "$file does not exist."
|
||||||
if(!((Get-Content $file) -ceq "Lorem ipsum dolor sit amet"))
|
exit 1
|
||||||
{
|
fi
|
||||||
Write-Error "File contents of downloaded artifact are incorrect"
|
shell: bash
|
||||||
}
|
|
||||||
shell: pwsh
|
|
||||||
|
|
||||||
# Download Artifact #2 and verify the correctness of the content
|
# Download Artifact #2 and verify the correctness of the content
|
||||||
- name: 'Download artifact #2'
|
- name: 'Download artifact #2'
|
||||||
|
@ -117,15 +126,13 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
$file1 = "some/other/path/to/dir-1/file1.txt"
|
$file1 = "some/other/path/to/dir-1/file1.txt"
|
||||||
$file2 = "some/other/path/to/dir-2/file2.txt"
|
$file2 = "some/other/path/to/dir-2/file2.txt"
|
||||||
if(!(Test-Path -path $file1) -or !(Test-Path -path $file2))
|
if test -f "$file" && test -f "$file2"; then
|
||||||
{
|
echo "$file exists."
|
||||||
Write-Error "Expected files do not exist"
|
else
|
||||||
}
|
echo "$file does not exist."
|
||||||
if(!((Get-Content $file1) -ceq "Lorem ipsum dolor sit amet") -or !((Get-Content $file2) -ceq "Hello world from file #2"))
|
exit 1
|
||||||
{
|
fi
|
||||||
Write-Error "File contents of downloaded artifacts are incorrect"
|
shell: bash
|
||||||
}
|
|
||||||
shell: pwsh
|
|
||||||
|
|
||||||
# Download Artifact #3 and verify the correctness of the content
|
# Download Artifact #3 and verify the correctness of the content
|
||||||
- name: 'Download artifact #3'
|
- name: 'Download artifact #3'
|
||||||
|
@ -138,15 +145,13 @@ jobs:
|
||||||
- name: 'Verify Artifact #3'
|
- name: 'Verify Artifact #3'
|
||||||
run: |
|
run: |
|
||||||
$gzipFile = "gzip/artifact/path/gzip.txt"
|
$gzipFile = "gzip/artifact/path/gzip.txt"
|
||||||
if(!(Test-Path -path $gzipFile))
|
if test -f "$gzipFile"; then
|
||||||
{
|
echo "$file exists."
|
||||||
Write-Error "Expected file do not exist"
|
else
|
||||||
}
|
echo "$file does not exist."
|
||||||
if(!((Get-Content $gzipFile) -ceq "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"))
|
exit 1
|
||||||
{
|
fi
|
||||||
Write-Error "File contents of downloaded artifact is incorrect"
|
shell: bash
|
||||||
}
|
|
||||||
shell: pwsh
|
|
||||||
|
|
||||||
- name: 'Download artifact #4'
|
- name: 'Download artifact #4'
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
|
@ -158,12 +163,10 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
$file1 = "multi/artifact/dir-1/file1.txt"
|
$file1 = "multi/artifact/dir-1/file1.txt"
|
||||||
$file2 = "multi/artifact/dir-2/file2.txt"
|
$file2 = "multi/artifact/dir-2/file2.txt"
|
||||||
if(!(Test-Path -path $file1) -or !(Test-Path -path $file2))
|
if test -f "$file1" && test -f "$file2"; then
|
||||||
{
|
echo "$file exists."
|
||||||
Write-Error "Expected files do not exist"
|
else
|
||||||
}
|
echo "$file does not exist."
|
||||||
if(!((Get-Content $file1) -ceq "Lorem ipsum dolor sit amet") -or !((Get-Content $file2) -ceq "Hello world from file #2"))
|
exit 1
|
||||||
{
|
fi
|
||||||
Write-Error "File contents of downloaded artifacts are incorrect"
|
shell: bash
|
||||||
}
|
|
||||||
shell: pwsh
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue