Skip to content

s-mokrushin/portainer-redeploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Portainer stack redeploy tool

Works only with stacks, configured by git repository.

What the script do:

  • Loads exist stack
  • Copies envs and auth params
  • Sends PUT request to api/stacks/[StackId]/git/redeploy

Build

docker build --tag=portainer-redeploy:latest .

Usage

Run Docker container

docker run --rm portainer-redeploy \
  --url=(Url) \
  --apiKey=(String) \
  --endpointId=(Int) \
  --stackName=(String) \
  --prune=1 # optional

Drone CI example

  - name: deploy
    image: organization/portainer-redeploy:latest
    entrypoint: []
    commands:
      - >
        if [ "$DRONE_COMMIT_BRANCH" = "develop" ]; then
          STACK_NAME=project-dev
        elif [ "$DRONE_COMMIT_BRANCH" = "release" ]; then
          STACK_NAME=project-stage
        elif [ "$DRONE_COMMIT_BRANCH" = "main" ]; then
          STACK_NAME=project-prod
        else
          echo "Stack name not found"
          exit 1
        fi

        python /app/main.py --url=$PORTAINER_URL \
          --apiKey=$PORTAINER_API_KEY --endpointId=1 --stackName=$STACK_NAME
    environment:
      PORTAINER_URL:
        from_secret: portainer_url
      PORTAINER_API_KEY:
        from_secret: portainer_api_key
    when:
      branch:
        - main
        - develop
        - release
      event:
        - push
    depends_on:
      - push-to-registry

About

Portainer stack redeploy tool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published