Skip to content

Commit

Permalink
Add Test (#7)
Browse files Browse the repository at this point in the history
* Add Test

* Update Test
  • Loading branch information
smashedr authored Jul 25, 2024
1 parent c03d933 commit 9e9b1a5
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 21 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: "Test"

on:
workflow_dispatch:
push:
paths:
- "src/**"
- "tests/**"

jobs:
test:
name: "Test"
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Test Local Action"
uses: ./
with:
token: ${{ secrets.PORTAINER_TOKEN }}
url: ${{ secrets.PORTAINER_URL }}
name: alpine-test
file: tests/docker-compose.yaml
type: file

lint:
name: "Lint"
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Setup Node"
uses: actions/setup-node@v4
with:
node-version: 20

- name: "ESLint"
run: |
npm install
npm run lint
build:
name: "Build"
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Setup Node"
uses: actions/setup-node@v4
with:
node-version: 20

- name: "Build"
run: |
npm install
npm run build
- name: "Verify"
run: |
git status --porcelain dist/
if [ ! -d "dist" ];then
echo "Missing dist directory, run: npm build"
exit 1
fi
if [ -n "$(git status --porcelain dist)" ];then
echo "Build was not run, run: npm build"
exit 1
fi
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
*.iml
.vscode/
node_modules/
.env
.secrets
.vars
56 changes: 37 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
[![Tags](https://img.shields.io/github/actions/workflow/status/cssnr/portainer-stack-deploy-action/tags.yaml?logo=github&logoColor=white&label=tags)](https://github.com/cssnr/portainer-stack-deploy-action/actions/workflows/tags.yaml)
[![Test](https://img.shields.io/github/actions/workflow/status/cssnr/portainer-stack-deploy-action/test.yaml?logo=github&logoColor=white&label=test)](https://github.com/cssnr/portainer-stack-deploy-action/actions/workflows/test.yaml)
[![GitHub Release Version](https://img.shields.io/github/v/release/cssnr/portainer-stack-deploy-action?logo=github)](https://github.com/cssnr/portainer-stack-deploy-action/releases/latest)
[![GitHub Top Language](https://img.shields.io/github/languages/top/cssnr/portainer-stack-deploy-action?logo=htmx&logoColor=white)](https://github.com/cssnr/portainer-stack-deploy-action)
[![GitHub Org Stars](https://img.shields.io/github/stars/cssnr?style=flat&logo=github&logoColor=white)](https://cssnr.github.io/)
[![Discord](https://img.shields.io/discord/899171661457293343?logo=discord&logoColor=white&label=discord&color=7289da)](https://discord.gg/wXy6m2X8wY)

# Portainer Stack Deploy Action

Deploy or Update a Portainer Stack from a GitHub Repository or Compose File. Supports most features including specifying
the repository, compose file, environment variables and much more...
Deploy or Update a Portainer Stack from a Repository or Compose File. Supports most features including specifying the
repository, compose file, environment variables and much more...

This action is written from the ground up in VanillaJS and is not a fork/clone of existing actions.

* [Inputs](#Inputs)
* [Examples](#Examples)
* [Troubleshooting](#Troubleshooting)
* [Support](#Support)
* [Contributing](#Contributing)

Expand All @@ -24,23 +26,23 @@ This action is written from the ground up in VanillaJS and is not a fork/clone o
## Inputs

| input | required | default | description |
|----------|----------|-------------------|-----------------------|
| token | **Yes** | - | Portainer Token * |
| url | **Yes** | - | Portainer URL |
| name | **Yes** | - | Stack Name |
| file | No | `compose.yaml` | Compose File |
| endpoint | No | `endpoints[0].Id` | Portainer Endpoint * |
| ref | No | `current ref` | Repository Ref * |
| repo | No | `current repo` | Repository URL * |
| tlsskip | No | `false` | Skip Repo TLS Verify |
| prune | No | `true` | Prune Services |
| pull | No | `true` | Pull Images |
| type | No | `repo` | Type `[repo, file]` * |
| env_json | No | - | Dotenv JSON Data * |
| env_file | No | - | Dotenv File Path * |
| username | No | - | Repository Username * |
| password | No | - | Repository Password * |
| input | required | default | description |
|----------|----------|-----------------------|-----------------------|
| token | **Yes** | - | Portainer Token * |
| url | **Yes** | - | Portainer URL |
| name | **Yes** | - | Stack Name |
| file | No | `docker-compose.yaml` | Compose File |
| endpoint | No | `endpoints[0].Id` | Portainer Endpoint * |
| ref | No | `current reference` | Repository Ref * |
| repo | No | `current repository` | Repository URL * |
| tlsskip | No | `false` | Skip Repo TLS Verify |
| prune | No | `true` | Prune Services |
| pull | No | `true` | Pull Images |
| type | No | `repo` | Type `[repo, file]` * |
| env_json | No | - | Dotenv JSON Data * |
| env_file | No | - | Dotenv File Path * |
| username | No | - | Repository Username * |
| password | No | - | Repository Password * |

**token** - To create a Portainer API token see: https://docs.portainer.io/api/access

Expand Down Expand Up @@ -187,6 +189,22 @@ jobs:
This is a fairly simple action, for more details see
[src/index.js](src%2Findex.js) and [src/portainer.js](src%2Fportainer.js).

## Troubleshooting

Some common errors you might see:

- No such image: ghcr.io/user/repo-name:tag

Make sure your package is not private. If you intend to use a private package, then:
Go to Portainer Registries: https://portainer.example.com/#!/registries/new
Choose Custom registry, set `ghcr.io` for Registry URL, enable authentication, and add your username/token.

- Error: Resource not accessible by integration

Only applies to `build-push-action` or `bake-action` type actions, not this action.
Go to your repository action settings: https://github.com/user/repo/settings/actions
Make sure Workflow permissions are set to Read and write permissions.

# Support

For general help or to request a feature, see:
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Portainer Stack Deploy Action"
description: "Deploy or Update a Portainer Stack from a GitHub Repository"
description: "Deploy or Update a Portainer Stack from a Repository or Compose File"
author: "Shane"
branding:
icon: "layers"
Expand All @@ -18,7 +18,7 @@ inputs:
file:
description: "Compose File"
required: false
default: "compose.yaml"
default: "docker-compose.yaml"
endpoint:
description: "Portainer Endpoint ID"
required: false
Expand Down
6 changes: 6 additions & 0 deletions tests/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: "3.8"

services:
alpine:
image: alpine
command: tail -f /dev/null

0 comments on commit 9e9b1a5

Please sign in to comment.