Skip to content

Instantly share code, notes, and snippets.

@marshyon
Last active December 7, 2022 13:32
Show Gist options
  • Save marshyon/30ec794c5c63120a0565f85a52da0338 to your computer and use it in GitHub Desktop.
Save marshyon/30ec794c5c63120a0565f85a52da0338 to your computer and use it in GitHub Desktop.
run_github_pipeline.sh
GITHUB_REPO=< repo url from github [Code] HTTPS ... but without 'https://' at the beginning >
GITHUB_TOKEN=< github token from Github 'user' settings, developer settings, Personal access tokens - create a token with code, workspace and org >
GITHUB_USER=< your github user account name >
CLONE_REPO_DIR=< path to the directory into which the repo will be copied / cloned >
GITHUB_WORKFLOW=< the file name of the github workflow file you want to be run - see the .github/workflows directory at the root of your repo >
#!/usr/bin/env bash
. .env
echo "cloning repo [${GITHUB_REPO}] with pipeline that we want to run ..."
[ -d $CLONE_REPO_DIR ] && echo "ERROR : the directory [${CLONE_REPO_DIR}] already exists, exiting ..." && exit 1
git clone "https://${GITHUB_USER}:${GITHUB_TOKEN}@${GITHUB_REPO}" $CLONE_REPO_DIR
cd ${CLONE_REPO_DIR}
echo "attemptiong to log in to a gitbub account ..."
echo $GITHUB_TOKEN | gh auth login --with-token
echo "attemptingt to run the pipeline for [${GITHUB_REPO}] ..."
gh workflow run ${GITHUB_WORKFLOW}
cd -
rm -rf ${CLONE_REPO_DIR}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment