Store job artifacts in GitHub.
This GitHub Action allows you to store artifacts generated during your workflow. It additionally supports packaging and storing AWS SAM artifacts for serverless applications.
For more information on what happens when use_aws_sam is true see ServerlessOpsIO/gha-package-aws-sam.
NOTE: This workflow is opinionated and meets the needs of its author. It is provided publicly as a reference for others to use and modify as needed.
The gha-store-artifacts action performs the following tasks:
- Optionally uploads a SAM artifact if specified.
- Uploads the job working directory as an artifact to GHA.
See below for inputs, outputs, and examples.
artifact_retention_days(optional): Number of days to retain artifacts..use_aws_sam(optional): Boolean to determine if SAM artifact should be uploaded.aws_account_region(optional): AWS region to use for SAM packaging.template_file(optional): Path to SAM template file.packaged_template_file(optional): Path to packaged SAM template file.sam_s3_bucket(optional): S3 bucket for SAM deployment.sam_s3_prefix(optional): S3 prefix for SAM deployment.
sam-artifact-bucket: The S3 bucket where the SAM artifact was uploaded.sam-artifact-bucket-prefix: The S3 prefix where the SAM artifact was uploaded.
To use this action see the examples below:
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setup job workspace
id: setup-workspace
uses: ServerlessOpsIO/gha-setup-workspace@v1
# Do job work here
- name: Store Artifacts
uses: ServerlessOpsIO/gha-store-artifacts@v1name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
# Required for AWS credentials
permissions:
id-token: write
contents: read
steps:
- name: Setup job workspace
id: setup-workspace
uses: ServerlessOpsIO/gha-setup-workspace@v1
# Do job work here
# NOTE: ERunning `sam build` prior ensures Lambda function dependencies will be properly
# bundled in the artifact.
- name: SAM build
id: sam-build
shell: bash
run: sam build
- name: Assume AWS Credentials
uses: ServerlessOpsIO/gha-assume-aws-credentials@v1
with:
build_aws_account_id: ${{ secrets.BUILD_AWS_ACCOUNT_ID }}
deploy_aws_account_id: ${{ secrets.DEPLOY_AWS_ACCOUNT_ID }}
aws_account_region: 'us-east-1'
gha_build_role_name: ${{ secrets.GHA_BUILD_ROLE_NAME }}
gha_deploy_role_name: ${{ secrets.GHA_DEPLOY_ROLE_NAME }}
- name: Store Artifacts
uses: ServerlessOpsIO/gha-store-artifacts@v1
with:
use_aws_sam: true
The default value for sam_s3_bucket comes from ServerlessOpsIO/aws-gha-integration. Both the sam_s3_bucket and sam_s3_prefix should not need to be configured but are avavailbel for unique circumstances.
Contributions are welcome! Please open an issue or submit a pull request for any changes.
For any questions or support, please open an issue in this repository.