Adding the "Amazon S3 publish" action
This section describes how to add the Amazon S3 publish action to your workflow. The Amazon S3 publish action copies files from a source directory to an Amazon S3 bucket. The source directory can reside in:
-
A source repository, or
-
An output artifact generated by another workflow action
Topics
When to use this action
Use this action if:
-
You have a workflow that generates files that you want to store in Amazon S3.
For example, you might have a workflow that builds a static website that you want to host in Amazon S3. In this case, your workflow would include a build action to build the site's HTML and supporting files, and an Amazon S3 publish action to copy the files to Amazon S3.
-
You have a source repository that contains files that you want to store in Amazon S3.
For example, you might have a source repository with application source files that you want to archive on a nightly basis to Amazon S3.
Example workflow
The following example workflow includes the Amazon S3 publish action, along with a build action. The workflow builds a static documentation website and then publishes it to Amazon S3, where it is hosted. The workflow consists of the following building blocks that run sequentially:
Note
The following workflow example is for illustrative purposes, and will only work with additional configuration.
-
A trigger – This trigger starts the workflow run automatically when you push a change to your source repository. For more information about triggers, see Working with triggers.
-
A build action (
BuildDocs
) – On trigger, the action builds a static documentation website (mkdocs build
) and adds the associated HTML files and supporting metadata to an artifact calledMyDocsSite
. For more information about the build action, see Building using workflows in CodeCatalyst. -
An Amazon S3 publish action (
PublishToS3
) – On completion of the build action, this action copies the site in theMyDocsSite
artifact to Amazon S3 for hosting.
Name: codecatalyst-s3-publish-workflow SchemaVersion: 1.0 Triggers: - Type: PUSH Branches: - main Actions: BuildDocs: Identifier: aws/build@v1 Inputs: Sources: - WorkflowSource Configuration: Steps: - Run: echo BuildDocs started on `date` - Run: pip install --upgrade pip - Run: pip install mkdocs - Run: mkdocs build - Run: echo BuildDocs completed on `date` Outputs: Artifacts: - Name: MyDocsSite Files: - "site/**/*" PublishToS3: Identifier: aws/s3-publish@v1 Environment: Name: codecatalyst-s3-publish-environment Connections: - Name: codecatalyst-account-connection Role: codecatalyst-s3-publish-build-role Inputs: Sources: - WorkflowSource Artifacts: - MyDocsSite Configuration: DestinationBucketName: my-bucket SourcePath: /artifacts/PublishToS3/MyDocSite/site TargetPath: my/docs/site
Adding the "Amazon S3 publish" action
Use the following instructions to add the Amazon S3 publish action to your workflow.
Variables produced by the "Amazon S3 publish" action
When the Amazon S3 publish action runs, it produces variables that you can use in subsequent workflow actions. For details, see "Amazon S3 publish" action variables in the List of predefined variables.
"Amazon S3 publish" action definition
The Amazon S3 publish action is defined as a set of YAML properties inside your workflow definition file. For information about these properties, see "Amazon S3 publish" action reference in the Workflow definition reference.