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 job of checkout (source or artifact)
- Checks out the source code if checkout_artifact is
false
. - Determines the artifact name based on the provided override or generates a default name.
- Downloads the artifact if checkout_artifact is
true
- .
See below for inputs, outputs, and examples.
artifact_name_override
(optional): Override the name of the artifact to use. Default is an empty string which determines the artifact name automatically.checkout_artifact
(optional): Whether to checkout artifact instead of source. Value must betrue
orfalse
.checkout_fetch_depth
(optional): The number of commits to fetch. Change to0
if performing a merge.
artifact-name
: The name of the artifact downloaded.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: true
See below for extended information on certain configuration.
Both ServerlessOpsIO/gha-setup-workspace and ServerlessOpsIO/gha-store-artifacts use the same utility action to set an artifact name if artifact_name_override
is not set. If your workflow sets artifact_name_override for ServerlessOpsIO/gha-setup-workspace
be sure to use that actions artifact_name output to set artifact_name_override for ServerlessOpsIO/gha-store-artifacts
.
See the example below:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setup job workspace
uses: ServerlessOpsIO/gha-setup-workspace@v1
- name: Store Artifacts
uses: ServerlessOpsIO/gha-store-artifacts@v1
with:
artifact_name_override: 'MyArtifactName'
outputs:
artifact-name: ${{ steps.setup-workspace.outputs.artifact-name }}
deploy:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Setup job workspace
uses: ServerlessOpsIO/gha-setup-workspace@v1
with:
checkout_artifact: true
artifact_name_override: ${{ needs.build.outputs.artifact-name }}
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.