diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f4047d0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +secret +my \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..965cb85 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +LABEL "com.github.actions.name"="WooCart Deploy" +LABEL "com.github.actions.description"="Deploy changes from your GitHUb repository to your store." +LABEL "com.github.actions.icon"="upload-cloud" +LABEL "com.github.actions.color"="blue" +LABEL "maintainer"="Niteo.co " + +FROM alpine:3.11 + +RUN apk add --no-cache bash curl unzip ca-certificates fuse openssh-client jq \ + && wget -qO- https://rclone.org/install.sh | bash \ + && apk del bash curl unzip + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0893ab5 --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +test: + env INPUT_URL=http://localhost:8080 INPUT_USERNAME=admin INPUT_PASSWORD=secret INPUT_REMOTE=/plugins/woocommerce INPUT_LOCAL=my/plugins/woocommerce bash entrypoint.sh + diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..3e84913 --- /dev/null +++ b/Readme.md @@ -0,0 +1,49 @@ +# WooCart Deploy Action + +Sync your GitHub repository with your store on WooCart.com. + +## Inputs + +### `url` + +**Required** The URL of WebDAV server (starting with https://...) + +### `username` + +**Required** The name of the user. + +### `password` + +**Required** The password for the user. + +### `local` + +**Required** Path in GitHub repository to sync. + +### `remote` + +**Required** Path on remote to sync into. + +## Example usage + +1. Create a `.github/workflows/deploy.yml` file in your GitHub repo, if one doesn't exist already. +2. Add the following code to the `deploy.yml` file. +```yaml +name: Deploy my-plugin +on: push +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Deploy my-plugin to WooCart + uses: woocart/deploy-action@v3 + with: + url: ${{ secrets.WEBDAV_URL }} + username: ${{ secrets.WEBDAV_USERNAME }} + password: ${{ secrets.WEBDAV_PASSWORD }} + local: "dist/" + remote: "plugins/my-plugin" +``` +3. Create `WEBDAV_URL`, `WEBDAV_USERNAME`, `WEBDAV_PASSWORD` secret using [GitHub Action's Secret](https://developer.github.com/actions/creating-workflows/storing-secrets). You can find these values in WooCart > Settings tab for your store. diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..12addbd --- /dev/null +++ b/action.yml @@ -0,0 +1,24 @@ +name: 'WooCart Deploy' +description: 'Deploy changes from your GitHUb repository to your store.' +inputs: + url: + description: 'WEBDAV url' + required: true + username: + description: 'WEBDAV user' + required: true + password: + description: 'WEBDAV password' + required: true + local: + description: 'Local directory' + required: true + remote: + description: 'Remote directory' + required: true +runs: + using: 'docker' + image: 'Dockerfile' +branding: + color: 'purple' + icon: 'upload-cloud' diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..ad0e54a --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2001,SC2002,SC2034,SC1090,SC2154,SC1117 + +# Fail fast and fail hard. +set -Eeuo pipefail + +mkdir -p ~/.config/rclone/ +echo " +[woocart] +type = webdav +pass = $(rclone obscure $INPUT_PASSWORD) +url = $INPUT_URL +user = $INPUT_USERNAME +vendor = other +" > ~/.config/rclone/rclone.conf + +rclone -v sync $INPUT_LOCAL woocart:$INPUT_REMOTE \ No newline at end of file