From d2f7cbac425b99d8cc15880e701151293f4bf50f Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 28 Dec 2023 01:00:46 -0500 Subject: [PATCH] refactor: switch to a docker action type --- Dockerfile | 15 +++++++++++++++ action.yml | 22 +++++++++++----------- entrypoint.sh | 18 ++++++++++++++++++ 3 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 Dockerfile create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..78bbdc6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +# Use a base image that includes necessary environments (e.g., Node.js) +FROM node:18.17.0 + +# Install Bun +RUN curl -fsSL https://bun.sh/install | bash + +# Set the working directory in the container +WORKDIR /usr/src/app + +# Copy your action's source files to the container +COPY . . + +# Command to run when the Docker container starts +# It assumes the entrypoint is a script that handles the inputs and runs the desired commands +ENTRYPOINT ["sh", "./entrypoint.sh"] diff --git a/action.yml b/action.yml index 11f405a..9a51f0c 100644 --- a/action.yml +++ b/action.yml @@ -1,20 +1,20 @@ name: 'web3.news Publisher' description: 'An action that publishes your site to the web3.news aggregator' runs: - using: 'composite' - steps: - - uses: oven-sh/setup-bun@v1 - with: - bun-version: 'latest' - - run: ls && bun ./src/index.ts - shell: bash + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.node }} + - ${{ inputs.seed }} + - ${{ inputs.folder }} inputs: node: - description: The S5 node to deploy to + description: 'The S5 node to deploy to' required: true seed: - description: Your site BIP39 seed + description: 'Your site BIP39 seed' required: true folder: - description: The folder to publish - default: public + description: 'The folder to publish' + required: false + default: 'public' diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..07ba4ab --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# Set the INPUT_* environment variables from script arguments +export INPUT_NODE=$1 +export INPUT_SEED=$2 +export INPUT_FOLDER=$3 + +# Providing a default value for INPUT_FOLDER if not set +if [ -z "$INPUT_FOLDER" ] +then + export INPUT_FOLDER="public" +fi + +echo "Publishing to node: $INPUT_NODE" +echo "Publishing folder: $INPUT_FOLDER" + +# Example command (replace with your actual command) +bun ./src/index.ts