Skip to content

Instantly share code, notes, and snippets.

@IlyaFinkelshteyn
Created July 7, 2017 01:10
Show Gist options
  • Save IlyaFinkelshteyn/def2394231afb7f06dcaeaceda1fb1ae to your computer and use it in GitHub Desktop.
Save IlyaFinkelshteyn/def2394231afb7f06dcaeaceda1fb1ae to your computer and use it in GitHub Desktop.
#GitHub_Token is secure variable
if ($env:APPVEYOR_PULL_REQUEST_NUMBER) {$env:CONTEXT = "continuous-integration/appveyor/pr"} else {$env:CONTEXT = "continuous-integration/appveyor/branch"}
$headers = @{
"Authorization" = "Bearer $env:GitHub_Token"
"Content-type" = "application/json"
}
$body = @{
state="pending"
target_url="https://ci.appveyor.com/project/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/build/$env:APPVEYOR_BUILD_VERSION"
description="Waiting for AppVeyor build to complete"
context=$env:CONTEXT
}
$body = $body | ConvertTo-Json
Invoke-RestMethod -Uri "https://api.github.com/repos/$env:APPVEYOR_REPO_NAME/statuses/$env:APPVEYOR_REPO_COMMIT" -Headers $headers -Body $body -Method POST
@Wasapl
Copy link

Wasapl commented Jul 19, 2018

#!/bin/bash

#GitHub_Token is secure variable

if [[ -n "${APPVEYOR_PULL_REQUEST_NUMBER}" ]]; then
    CONTEXT="continuous-integration/appveyor/pr"
else
    CONTEXT="continuous-integration/appveyor/branch"
fi

BODY="
{
  \"context\": \"${CONTEXT}\",
  \"target_url\": \"https://ci.appveyor.com/project/${APPVEYOR_ACCOUNT_NAME}/${APPVEYOR_PROJECT_SLUG}/build/${APPVEYOR_BUILD_VERSION}\",
  \"state\": \"pending\",
  \"description\": \"Waiting for AppVeyor build to complete\"
}
"

curl -X POST "https://api.github.com/repos/${APPVEYOR_REPO_NAME}/statuses/${APPVEYOR_REPO_COMMIT}" \
 -H "Authorization: token  ${GitHub_Token}" \
 -H "Content-type: application/json" \
 -d "${BODY}" 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment