Creating custom GitHub Action using Deno
Hey, I am currently trying to develop my first own custom GitHub Action. I have some trouble setting up my environment. I really don't want to use Node and try to stick to Deno, but this is easier said than done.
Can someone help me setting a basic action up? Thanks!
This is my current repo where I try to set everything up: https://github.com/Datapack-Registry/minecraft-manifest
6 Replies
I have already look into this official template, but this is for Node only... https://github.com/actions/typescript-action/tree/main
Hello there! 🦕 It's great to hear that you're looking to create a custom GitHub Action using Deno. Setting up a GitHub Action with Deno is quite straightforward, and I can guide you through the basic setup.
Here's a simple workflow that you can use as a starting point for your GitHub Action:
In this workflow:
- The action is triggered on push and pull request events to the
main
branch.
- It sets up a job called build
that runs on the latest Ubuntu runner.
- The actions/checkout@v2
step checks out your repository code.
- The denoland/setup-deno@main
step sets up Deno on the runner. You can specify the Deno version you want to use with the deno-version
input.
- Finally, the Run custom Deno script
step executes your Deno script using deno run
. Replace your-script.ts
with the path to your Deno script in the repository.
Make sure to adjust the permissions and flags according to your script's requirements. For example, if your script doesn't need access to all permissions, you should remove --allow-all
and specify only the permissions your script needs.
You can place this workflow in a .github/workflows
directory in your repository. For example, you could name the file deno-action.yml
.
Remember to also check the documentation for any specific configurations you might need, especially if you're planning to use Deno Deploy or other Deno-specific features. Thedocumentation provides detailed guidance on setting up GitHub Actions with Deno, including how to use the
deployctl
GitHub action if you're deploying to Deno Deploy.
I hope this helps you get started with your custom GitHub Action using Deno! If you have any more questions or need further assistance, feel free to ask. Good luck with your project! 🦕That’s not what I want to achieve. I don’t want to build a workflow where I use Deno, I want to build my own custom action using Deno as runtime.
Apologies for the confusion. To create a custom GitHub Action using Deno as the runtime, you'll need to create a Docker container action that uses Deno. Here's a basic setup for a custom GitHub Action using Deno:
1. Create a
Dockerfile
in your GitHub repository that sets up Deno. Here's an example Dockerfile
:
2. Create an entrypoint.sh
script that will run your Deno code. Here's an example entrypoint.sh
:
Make sure to replace your-script.ts
with the path to your Deno script and adjust the permissions as needed.
3. Create your Deno script (e.g., your-script.ts
) that contains the logic for your GitHub Action.
4. Create an action.yml
file in the root of your repository that defines your action's inputs, outputs, and runs the Docker container. Here's an example action.yml
:
5. Push these changes to your repository.
This setup defines a custom GitHub Action that runs a Deno script inside a Docker container. When you use this action in a workflow,GitHub will build the Docker container using the
Dockerfile
and then run the container with the entrypoint.sh
script as the entry point.
Please note that the advice provided here is not directly from the Deno documentation, and you should double-check the accuracy of the advice given. If you encounter any issues or have further questions, feel free to ask for assistance. Good luck with your Deno-based GitHub Action!