GitHub Action
Speckle Automate function version publisher
This repository contains the source code for the Speckle Automate GitHub Action. It is a GitHub Action that publishes a Speckle Automate Function definition to Speckle's automation platform.
Note
This is a low level building block action. As a Speckle Automate Function developer you probably want to use our composite action
The URL of the Speckle Automate Server to publish the function to.
Defaults to https://automate.speckle.dev
.
The Speckle Automate API token to use to publish the function. This token must have functions:write
permissions.
This must be stored in GitHub as an encrypted secret. This token must be protected, as it allows anyone with access to it to publish functions as you to your Speckle Automate Server.
If you believe your token has been compromised, please revoke it immediately on your Speckle Automate Server. Please also audit your Speckle Automate Function changes to ensure that they were not made by an unauthorized party.
Please note that this is not a Speckle Account token, but a Speckle Automate API token. You can create one by logging into the Speckle Automate Server and going to the API Tokens page.
The path to the Speckle Automate Function to publish. This path is relative to the root of the repository. If you provide a path to a directory, your Speckle Automate Function must be in a file named specklefunction.yaml
within that directory.
Optional. If you have already registered a Speckle Function, you can use the ID of that Speckle Function to ensure that any changes are associated with it. If you do not provide a Function Id, we will attempt to determine the Function ID based on the GitHub server, GitHub repository, Reference (branch), and the Speckle Function Path.
Providing a Speckle Function ID allows you to change one of those values, and update the original Function instead of creating a new one.
Your Speckle Token must have write permissions for the Speckle Function with this ID, otherwise the publish will fail.
The unique ID of this version of the published function.
The host component of the Speckle Automate Server URL.
Speckle Automate GitHub Action will register a Speckle Function with Speckle Automate. This is a necessary, but not sufficient, step in publishing your Speckle Function. You must also build and push the Docker image that contains your Speckle Function.
uses: actions/[email protected]
with:
# speckle_automate_url is optional and defaults to https://automate.speckle.dev
# The speckle_token is a secret and must be stored in GitHub as an encrypted secret
# https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
speckle_token: ${{ secrets.SPECKLE_TOKEN }}
# speckle_function_path is optional and defaults to ./specklefunction.yaml
# speckle_function_id is optional and will be auto-generated if not provided
uses: actions/[email protected]
with:
# please update to the url of your self-hosted server
speckle_automate_url: https://example.org
# https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
speckle_token: ${{ secrets.SPECKLE_TOKEN }}
# speckle_function_path is optional and defaults to ./specklefunction.yaml
# speckle_function_id is optional and will be auto-generated if not provided
Docker is the original, and still one of the most popular, ways to build and publish Docker images. It does require that you provide a Dockerfile, which includes instructions to Docker for building your image.
Find out more about Docker and Dockerfiles by following Docker's Get Started Guide.
You can learn more about Docker's GitHub Action from their documentation in the GitHub Actions Marketplace.
name: ci
on:
push:
branches:
- 'main'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
# Checkout the code
# Docker's GitHub Action does not require this step
# but Speckle Automate does
name: Checkout
uses: actions/checkout@v3
-
id: speckle
name: Register Speckle Function
uses: actions/[email protected]
with:
speckle_token: ${{ secrets.SPECKLE_TOKEN }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Docker needs to login to Speckle Automate
uses: docker/login-action@v2
with:
username: ${{ secrets.SPECKLE_USERNAME }}
password: ${{ secrets.SPECKLE_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v4
with:
# ## file is optional and defaults to {context}/Dockerfile
# file: ./Dockerfile
# ## context is optional and defaults to the root directory '.' of the repository
# context: .
# ## platforms is optional and defaults to linux/amd64
# ## platforms must match the platforms that you have registered with Speckle Automate, which also defaults to linux/amd64.
# platforms: linux/amd64
push: true
tags: ${{ steps.speckle.outputs.image_name }}
- Clone this repository
- Run
yarn install
to install dependencies. - Run
yarn run all
to validate, build, and test the project.
- Docker
- Node.js (v18)
- Yarn
- Pre-Commit
- Clone this repository
- Run
pre-commit install
to install the pre-commit hooks - Run
yarn install
to install dependencies
-
Run unit tests with coverage:
yarn test
-
Run unit tests and watch for changes while developing:
yarn test:watch
- Run
yarn precommit
to run all pre-commit hooks. - You must address all linting errors prior to committing changes. The CI will fail if there are any linting errors, and you will be unable to merge your PR.
Please make sure you read the contribution guidelines and code of conduct for an overview of the practices we try to follow.
The Speckle Community hangs out on the forum, do join and introduce yourself & feel free to ask us questions!
For any security vulnerabilities or concerns, please contact us directly at security[at]speckle.systems.
Unless otherwise described, the code in this repository is licensed under the Apache-2.0 License. Please note that some modules, extensions or code herein might be otherwise licensed. This is indicated either in the root of the containing folder under a different license file, or in the respective file's header. If you have any questions, don't hesitate to get in touch with us via email.