This GitHub Action sets up the job workspace by checking the job type, optionally checking out the source code, and handling artifacts based on the job type.
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-setup-workspace action performs the following tasks:
- Sets additional GitHub Actions environment variables.
- Checks the checkout type (source or artifact).
- Checks out the source code if checkout_artifact is
false. - Downloads the artifact if checkout_artifact is
true.
See below for inputs, outputs, and examples.
checkout_artifact(optional): Whether to checkout artifact instead of source. Value must betrueorfalse. When set totrue, this action downloads artifacts using the default behavior ofactions/download-artifact.checkout_fetch_depth(optional): The number of commits to fetch. Change to0if performing a merge.
When checkout_artifact is true, this action does not specify an artifact name when downloading artifacts.
As a result, it relies on the default behavior of actions/download-artifact, which downloads all available artifacts for the workflow run when no name is provided.
If your workflow expects exactly one artifact to be present in the workspace, configure upstream jobs to upload only one artifact for that run. If multiple artifacts are uploaded, all of them may be downloaded into the workspace.
When checkout_artifact is true, this action does not specify an artifact name when downloading artifacts.
As a result, it relies on the default behavior of actions/download-artifact, which downloads all available artifacts for the workflow run when no name is provided.
If your workflow expects exactly one artifact to be present in the workspace, configure upstream jobs to upload only one artifact for that run. If multiple artifacts are uploaded, all of them may be downloaded into the workspace.
is-artifact: Checkout type is artifact.is-source: Checkout type is source.
To use this action, add the following step to your workflow:
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setup job workspace
uses: ServerlessOpsIO/gha-setup-workspace@v1
deploy:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Setup job workspace
uses: ServerlessOpsIO/gha-setup-workspace@v1
with:
checkout_artifact: trueContributions 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.