Git Product home page Git Product logo

Comments (1)

probonopd avatar probonopd commented on September 20, 2024

I can call trigger leafpad subsurface to start parallel builds of these two applications.

#!/bin/bash

# Trigger builds on travis using GitHub username and password
# https://docs.travis-ci.com/api?http#creating-a-temporary-github-token

set +e

USERNAME=probonopd
PROJECT=AppImages

USER_AGENT='Travis/1.8.0 (Compatible; curl '$(curl --version | head -n 1 | cut -d " " -f 1-4)')'

echo $@
MATRIX=""
for RECIPE in $@ ; do
  MATRIX="\"RECIPE=$RECIPE\",$MATRIX"
done
MATRIX=$(echo -n $MATRIX | head -c -1 ) # Remove extra comma at the end

read -s -p "GitHub Password: " PASSWORD
if [ "$PASSWORD" == "" ] ; then
  exit 1
else
  echo ""
fi

#########################################################
echo "Delete the GitHub authorization at the end"
#########################################################

trap atexit EXIT

atexit()
{    
  set +e

  RESL=$(curl -u $USERNAME:$PASSWORD -k -s -X DELETE \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    $GH_AUTH_URL)

  echo $RESL
}

#########################################################
echo "Create a temporary GitHub authorization"
#########################################################

body='{
  "scopes": [
    "read:org", "user:email", "repo_deployment",
    "repo:status", "write:repo_hook"
  ],
  "note": "temporary token to auth against travis"
}'

RES1=$(curl -k -u $USERNAME:$PASSWORD -s -X POST \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d "$body" \
  https://api.github.com/authorizations)

echo $RES1

GH_TOKEN=$(echo $RES1 | grep -Po '"token":.*?[^\\]",' | cut -d '"' -f 4 | head -n 1)
GH_AUTH_URL=$(echo $RES1 | grep -Po '"url":.*?[^\\]",' | cut -d '"' -f 4| head -n 1)

#########################################################
echo "Get a travis token using the GitHub token"
#########################################################

RES2=$(curl -A "$USER_AGENT" -k -s -X POST \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{"github_token":"'$GH_TOKEN'"}' \
  https://api.travis-ci.org/auth/github)

echo $RES2

TRAVIS_TOKEN=$(echo $RES2 | cut -d '"' -f 4 | head -n 1)
echo $TRAVIS_TOKEN

[ $TRAVIS_TOKEN == "error" ] && exit 1

#########################################################
echo "Trigger a build"
#########################################################

body='{
  "request": {
    "message": "Build triggered by api request",
    "branch":"master",
    "config": {
      "env": {
        "matrix": ['$MATRIX']
      }
    }
  }
}'
echo $body
curl -A "$USER_AGENT" -k -s -X POST \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Travis-API-Version: 3" \
  -H "Authorization: token $TRAVIS_TOKEN" \
  -d "$body" \
  https://api.travis-ci.org/repo/$USERNAME%2F$PROJECT/requests

from pkg2appimage.

Related Issues (20)

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.