# Action's main infoname:"SapperAction"description:"BuildyourSapper-basedstaticwebsite"# Action's author nameauthor:"VicShΓ³stak"# Action's branding data for GitHub Marketplace# See docs: [1]branding:icon:"package"# icon name from Feather open source icons packcolor:"blue"# Action's inputs (options)# See docs: [2]inputs:# First input (option) name# See docs: [3]build_mode:# Input's descriptiondescription:"BuildmodetotheSapper(couldbe`build`or`export`,bydefault`export`)"# Specify, if this input is required to definerequired:false# Input's default valuedefault:"export"# Second input (option) nameargs:description:"ArgumentstopasstotheSapperinvocation(bydefault`--legacy`)"required:falsedefault:"--legacy"# Configures the image (used for the Docker action)# See docs: [4]runs:# Use Docker to run the action using:"docker"# The Docker image to use as the container to run the action# or path to 'Dockerfile' with settingsimage:"Dockerfile"
Yeah, as you have already understood, this is a regular Dockerfile with container settings (the same as you usually use in your projects):
# Select the Docker imageFROM node:10-alpine# Copy `entrypoint.sh` file to container's rootCOPY entrypoint.sh /# Set permissions for `entrypoint.sh` file execution RUN chmod +x /entrypoint.sh
# Define an entrypoint to be called after the container is createdENTRYPOINT ["/entrypoint.sh"]
βοΈ Tip: please read The Best practices for writing Dockerfileshere.
Pay attention, $INPUT_BUILD_MODE is equal to inputs.build_mode in actions.yml file and the same logic also applies to $INPUT_ARGS (inputs.args). In other words, all variables, that you would allow for definition to your users should be defined as $INPUT_<OPTION_NAME>.
Conditional operator example
If some variable is specific, you can define it with a boolean variable in action.yml and then, check in entrypoint.sh.
Specify a new input for inputs section into action.yml:
Documentation and usage examples in README.md are the most important parts of your GitHub action. Because, your action (possibly) will be used by other developers! Always remember that, when you create a new action.
Here are some simple rules to help you write really good docs:
Write a detailed start guide right at the beginning.
Format all optional values (inputs) in tabular format, following the string structure: Input name, Is required?, Default value, Description.
Add more examples, especially, if your action can be built into a chain of actions or used only in combination with another GitHub action.
Add beautiful and understandable image cover for preview of your GitHub repository. This is also important, because when people sharing link of your GitHub action, will see an attractive preview that can create a great conversion!
βοΈ Tip: You can download a special template (with safe indents) to create a cover image for preview of your repository.
(advanced) Add a demo repository with an example of how to apply your GitHub action, such as I did for action of this example:
Okay! π We are now fully ready to publish your first action to the GitHub Actions Marketplace.
Go to Releases page in your repository and draft new release.
Check Publish this Action to the GitHub Marketplace.
GitHub will check all the files related to the action and will show warnings, if something doesn't comply with best practices or/and community agreements.
If you did everything right, then on the main page of your repository will be added a badge with an invitation to view this action on the GitHub Marketplace:
True web artisans actions-sapper repository (link)
P.S.
If you want more articles (like this) on this blog, then post a comment below and subscribe to me. Thanks! π»
βοΈ You can support me on Boosty, both on a permanent and on a one-time basis. All proceeds from this way will go to support my OSS projects and will energize me to create new products and articles for the community.
And of course, you can help me make developers' lives even better! Just connect to one of my projects as a contributor. It's easy!
My main projects that need your help (and stars) π
π₯ gowebly: A next-generation CLI tool that makes it easy to create amazing web applications with Go on the backend, using htmx, hyperscript or Alpine.js and the most popular CSS frameworks on the frontend.
β¨ create-go-app: Create a new production-ready project with Go backend, frontend and deploy automation by running one CLI command.