Simplify upload scripts

This commit is contained in:
rodelgc 2023-03-18 08:29:56 +08:00
parent 2110d011ae
commit 45071f2f03
6 changed files with 45 additions and 58 deletions

View File

@ -3,8 +3,8 @@ description: Upload Allure files to bucket.
permissions: {}
inputs:
destination-dir:
description: Directory under the "artifacts" S3 folder to which the Allure files would be uploaded.
artifact-name:
description: Name of the artifact that contains the allure-report and/or allure-results folders.
required: true
aws-region:
required: true
@ -27,26 +27,11 @@ runs:
aws-access-key-id: ${{ inputs.aws-access-key-id }}
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
- name: Verify allure-results and allure-report paths
uses: actions/github-script@v6
with:
script: |
const script = require('./.github/actions/tests/upload-allure-files-to-bucket/scripts/verify-allure-dirs.js')
script({core})
- name: Upload 'allure-results' folder
if: inputs.include-allure-results == true
- name: Upload Allure artifact
env:
ARTIFACT_NAME: ${{ inputs.artifact-name }}
S3_BUCKET: ${{ inputs.s3-bucket }}
INCLUDE_ALLURE_RESULTS: ${{ inputs.include-allure-results }}
shell: bash
working-directory: .github/actions/tests/upload-allure-files-to-bucket/scripts
run: bash upload-allure-results.sh
env:
DESTINATION_DIR: ${{ inputs.destination-dir }}
S3_BUCKET: ${{ inputs.s3-bucket }}
- name: Upload 'allure-report' folder
shell: bash
working-directory: .github/actions/tests/upload-allure-files-to-bucket/scripts
run: bash upload-allure-report.sh
env:
DESTINATION_DIR: ${{ inputs.destination-dir }}
S3_BUCKET: ${{ inputs.s3-bucket }}
run: bash upload-allure-artifact.sh

View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
upload_allure_results () {
if [[ $INCLUDE_ALLURE_RESULTS != "true" ]]; then
return
fi
SOURCE="$ALLURE_RESULTS_DIR"
DESTINATION="$S3_BUCKET/artifacts/$GITHUB_RUN_ID/$DESTINATION_DIR/allure-results"
aws s3 cp "$SOURCE" "$DESTINATION" \
--recursive \
--only-show-errors
}
upload_allure_report () {
SOURCE="$ALLURE_REPORT_DIR"
DESTINATION="$S3_BUCKET/artifacts/$GITHUB_RUN_ID/$DESTINATION_DIR/allure-report"
aws s3 cp "$SOURCE" "$DESTINATION" \
--recursive \
--only-show-errors
}
upload_allure_results
upload_allure_report
EXIT_CODE=$(echo $?)
exit $EXIT_CODE

View File

@ -1,8 +0,0 @@
#!/usr/bin/env bash
echo "Uploading allure-report folder..."
aws s3 cp $ALLURE_REPORT_DIR \
"$S3_BUCKET/artifacts/$GITHUB_RUN_ID/$DESTINATION_DIR/allure-report" \
--recursive \
--only-show-errors
echo "Done"

View File

@ -1,8 +0,0 @@
#!/usr/bin/env bash
echo "Uploading allure-results folder..."
aws s3 cp $ALLURE_RESULTS_DIR \
"$S3_BUCKET/artifacts/$GITHUB_RUN_ID/$DESTINATION_DIR/allure-results" \
--recursive \
--only-show-errors
echo "Done"

View File

@ -1,11 +0,0 @@
module.exports = ( { core } ) => {
const { ALLURE_REPORT_DIR, ALLURE_RESULTS_DIR } = process.env;
if ( ! ( ALLURE_REPORT_DIR || ALLURE_RESULTS_DIR ) ) {
const errorMessage =
'You tried to use the "upload-allure-files-to-bucket" action without specifying the path to the allure-results and/or allure-report folders.\n' +
'To use this action, set the paths using the ALLURE_REPORT_DIR and ALLURE_RESULTS_DIR environment variables.';
core.setFailed( errorMessage );
}
};

View File

@ -103,7 +103,7 @@ jobs:
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
destination-dir: ${{ env.E2E_WP_LATEST_ARTIFACT }}
artifact-name: ${{ env.E2E_WP_LATEST_ARTIFACT }}
s3-bucket: ${{ secrets.REPORTS_BUCKET }}
- name: Publish E2E Allure report
@ -159,7 +159,7 @@ jobs:
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
destination-dir: ${{ env.API_WP_LATEST_ARTIFACT }}
artifact-name: ${{ env.API_WP_LATEST_ARTIFACT }}
s3-bucket: ${{ secrets.REPORTS_BUCKET }}
- name: Publish API Allure report
@ -250,7 +250,7 @@ jobs:
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
destination-dir: ${{ env.E2E_WP_LATEST_ARTIFACT }}
artifact-name: ${{ env.E2E_WP_LATEST_ARTIFACT }}
s3-bucket: ${{ secrets.REPORTS_BUCKET }}
- name: Publish E2E Allure report
@ -376,7 +376,7 @@ jobs:
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
destination-dir: ${{ env.API_WP_LATEST_X_ARTIFACT }}
artifact-name: ${{ env.API_WP_LATEST_X_ARTIFACT }}
s3-bucket: ${{ secrets.REPORTS_BUCKET }}
- name: Publish API Allure report
@ -418,7 +418,7 @@ jobs:
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
destination-dir: ${{ env.E2E_WP_LATEST_X_ARTIFACT }}
artifact-name: ${{ env.E2E_WP_LATEST_X_ARTIFACT }}
s3-bucket: ${{ secrets.REPORTS_BUCKET }}
- name: Publish E2E Allure report
@ -499,7 +499,7 @@ jobs:
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
destination-dir: ${{ env.API_ARTIFACT }}
artifact-name: ${{ env.API_ARTIFACT }}
s3-bucket: ${{ secrets.REPORTS_BUCKET }}
- name: Publish API Allure report
@ -541,7 +541,7 @@ jobs:
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
destination-dir: ${{ env.E2E_ARTIFACT }}
artifact-name: ${{ env.E2E_ARTIFACT }}
s3-bucket: ${{ secrets.REPORTS_BUCKET }}
- name: Publish E2E Allure report
@ -643,7 +643,7 @@ jobs:
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
destination-dir: ${{ env.ARTIFACT_NAME }}
artifact-name: ${{ env.ARTIFACT_NAME }}
s3-bucket: ${{ secrets.REPORTS_BUCKET }}
- name: Publish E2E Allure report