GithubHelp home page GithubHelp logo

drone-activitypub's Introduction

USAGE

This bot will inspect the status of a drone repo and publish it to a server that speaks activitypub (ie, mastodon)

The first time you use it, it will ask you to authenticate with the mastodon server, it will ask you to follow some steps and then you will need to save the data you can use the following script:

Script

#!/bin/bash

# The message to post:
# See below how to customize the posted message
export DRONE_OWNER=$drone_owner

# Mastodon variables
export DRONE_MASTODON_URL=$your_instance
export DRONE_MASTODON_DATA=$leave_empty

# ./target/release/drone-activitypub
docker run \
    -e DRONE_MESSAGE=${DRONE_MESSAGE} \
    -e DRONE_MASTODON_URL=${DRONE_MASTODON_URL} \
    -e DRONE_MASTODON_DATA=${DRONE_MASTODON_DATA} \
    --rm zentauro/drone-activitypub:v2.0.0

Inside drone

This is an example of how to use it:

---
kind: pipeline
name: mastodon

steps:
- name: message
  image: "zentauro/drone-activitypub:0.0.1"
  settings:
    message: $message_template
    mastodon_url: $mastodon_url
    mastodon_data: $mastodon_auth_data

Message templates

message: |
  {{ #success build.status }}
    Build {{ build.number }} pushed by {{ commit.author }} caused by {{ build.event }} at {{ repo.name }} succeded
  {{ else }}
    Build {{ build.number }} pushed by {{ commit.author }} caused by {{ build.event }} at {{ repo.name }} failed
  {{ /success }}

The plugin developer docs aren't really clear about what variables are passed to the plugins, so please take this list with a grain of salt as it is a best effort.

Template variables

  • repo.owner: repository owner
  • repo.name: repository name
  • build.status: build status enumeration
    • success
    • failure
  • build.event: build event enumeration
    • push
    • pull_request
    • tag
    • deployment
  • build.number: build number
  • build.commit: git sha for current commit
  • build.branch: git branch for current commit
  • build.tag: git tag for current commit
  • build.ref: git ref for current commit
  • build.author: git author for current commit
  • build.link: link the the build results in drone
  • build.started: unix timestamp for build started
  • build.finished: unix timestamp for build finished

Template functions

  • uppercasefirst converts the first letter of a string to uppercase
  • uppercase converts a string to uppercase
  • lowercase converts a string to lowercase. Example {{lowercase build.author}}
  • datetime converts a unix timestamp to a date time string. Example {{datetime build.started}}
  • success returns true if the build is successful
  • failure returns true if the build is failed
  • truncate returns a truncated string to n characters. Example {{truncate build.sha 8}}
  • urlencode returns a url encoded string
  • since returns a duration string between now and the given timestamp. Example {{since build.started}}

Sources of the variables

License

The entire contents of this repository are distributed under the terms of the GNU Affero General Public License unless explicitly stated.


drone-activitypub a drone plugin to post to mastodon

Copyright © 2019 zentauro

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses/.

drone-activitypub's People

Contributors

zentauro avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.